Arithmetic/Rational: Difference between revisions

Content added Content deleted
m (→‎{{header|C sharp}}: Regularize header markup to recommended on category page)
(Added Arturo implementation)
Line 342: Line 342:
Sum of reciprocal factors of 523776 = 2 exactly, about 2.0000000000000000000000000005
Sum of reciprocal factors of 523776 = 2 exactly, about 2.0000000000000000000000000005
</pre>
</pre>

=={{header|Arturo}}==

Arturo comes with built-in support for rational numbers.

<lang rebol>a: to :rational [1 2]
b: to :rational [3 4]

print ["a:" a]
print ["b:" b]

print ["a + b :" a + b]
print ["a - b :" a - b]
print ["a * b :" a * b]
print ["a / b :" a / b]
print ["a // b :" a // b]
print ["a % b :" a % b]

print ["reciprocal b:" reciprocal b]
print ["neg a:" neg a]

print ["pi ~=" to :rational 3.14]</lang>

{{out}}

<pre>a: 1/2
b: 3/4
a + b : 5/4
a - b : -1/4
a * b : 3/8
a / b : 0
a // b : 2/3
a % b : 1/2
reciprocal b: 4/3
neg a: -1/2
pi ~= 157/50</pre>


=={{header|BBC BASIC}}==
=={{header|BBC BASIC}}==