Convert decimal number to rational: Difference between revisions
Use the function fraction
m (→{{header|TI SR-56}}: Terminology) |
(Use the function fraction) |
||
Line 2,807:
=={{header|Seed7}}==
The library [http://seed7.sourceforge.net/libraries/bigrat.htm bigrat.s7i]
defines the
which creates a [https://seed7.sourceforge.net/manual/types.htm#bigRational bigRational] number from a string.
Internally a bigRational uses numerator and denominator to represent a rational number.
Writing a bigRational does not create a fraction with numerator and denominator, but a decimal number with possibly repeating decimals.
The function [https://seed7.sourceforge.net/libraries/bigrat.htm#fraction(in_bigRational) fraction]
uses numerator and denominator from the bigRational number to get a string with the fraction.
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "bigrat.s7i";
Line 2,814 ⟶ 2,819:
const proc: main is func
begin
writeln(fraction(bigRational
writeln(fraction(bigRational
writeln(fraction(bigRational
writeln(fraction(bigRational
writeln(fraction(bigRational
writeln(fraction(bigRational
writeln(fraction(bigRational
writeln(fraction(bigRational
writeln(fraction(bigRational
writeln(fraction(bigRational
writeln(fraction(bigRational
writeln(fraction(bigRational
writeln(fraction(bigRational
end func;
</syntaxhighlight>
{{out}}
<pre>67/74
|