Skip to content

Commit

Permalink
Simplify before toFloat conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
olsavmic committed Aug 4, 2022
1 parent de84657 commit 0af55b5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/BigRational.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down

0 comments on commit 0af55b5

Please sign in to comment.