Anonymous user
Convert decimal number to rational: Difference between revisions
Convert decimal number to rational (view source)
Revision as of 15:49, 25 October 2019
, 4 years ago→{{header|Nim}}
Line 1,533:
proc `$`(self: Rational): string =
if self.denominator == 1:
$self.numerator & "//" & $self.denominator▼
$self.numerator
else:
▲ $self.numerator & "//" & $self.denominator
func rationalize(x: float, tol: float = epsilon(float)): Rational =
Line 1,586 ⟶ 1,589:
3//4
1//7
35
35001//1000
9//10
|