From 0af55b5b654d26f0d66604d02b18419a0c927375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Ols=CC=8Cavsky=CC=81?= Date: Thu, 4 Aug 2022 16:53:59 +0200 Subject: [PATCH] Simplify before toFloat conversion --- src/BigRational.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BigRational.php b/src/BigRational.php index 9f7ccae..4625781 100644 --- a/src/BigRational.php +++ b/src/BigRational.php @@ -429,7 +429,8 @@ public function toInt() : int */ public function toFloat() : float { - return $this->numerator->toFloat() / $this->denominator->toFloat(); + $simplified = $this->simplified(); + return $simplified->numerator->toFloat() / $simplified->denominator->toFloat(); } /**