Anonymous user
Convert decimal number to rational: Difference between revisions
Convert decimal number to rational (view source)
Revision as of 20:42, 16 August 2012
, 11 years agoMoved MATLAB to its proper place in the alphabetic order of languages. -- ~~~~
Walterpachl (talk | contribs) m (NetRexx moved to its proper place) |
(Moved MATLAB to its proper place in the alphabetic order of languages. -- ~~~~) |
||
Line 485:
x: x:inv 67r74 42r81 3r4 NB. invertible
67r74 14r27 3r4</lang>
=={{header|MATLAB}} / {{header|Octave}}==▼
<lang Matlab>▼
[a,b]=rat(.75)▼
[a,b]=rat(.518518)▼
[a,b]=rat(.9054054)▼
</lang>▼
Output:▼
<pre>▼
>> [a,b]=rat(.75)▼
a = 3▼
b = 4▼
>> [a,b]=rat(.518518)▼
a = 37031▼
b = 71417▼
>> [a,b]=rat(.9054054)▼
a = 67▼
b = 74▼
</pre>▼
=={{header|PARI/GP}}==
Line 630 ⟶ 610:
<lang Mathematica>Map[Rationalize[#,0]&,{0.9054054,0.518518, 0.75} ]
-> {4527027/5000000,259259/500000,3/4}</lang>
▲=={{header|MATLAB}} / {{header|Octave}}==
▲<lang Matlab>
▲ [a,b]=rat(.75)
▲ [a,b]=rat(.518518)
▲ [a,b]=rat(.9054054)
▲</lang>
▲Output:
▲<pre>
▲ >> [a,b]=rat(.75)
▲ a = 3
▲ b = 4
▲ >> [a,b]=rat(.518518)
▲ a = 37031
▲ b = 71417
▲ >> [a,b]=rat(.9054054)
▲ a = 67
▲ b = 74
▲</pre>
=={{header|NetRexx}}==
|