Arithmetic/Integer: Difference between revisions

m
→‎{{header|ALGOL 68}}: ALGOL 68R has a non-standard '%:=' operator - update
No edit summary
m (→‎{{header|ALGOL 68}}: ALGOL 68R has a non-standard '%:=' operator - update)
Line 484:
<lang algol68>main:(
LONG INT a=355, b=113;
printf(($"a PLUS b = a+b = "gl$, a + b));
printf(($"a MINUS b = a-b = "gl$, a - b));
printf(($"a TIMES b = a*b = a×b = "gl$, a * b));
printf(($"a DIV b = a/b = "gl$, a / b));
printf(($"a OVER b = a%b = a÷b = "gl$, a % b));
printf(($"a MOD b = a%*b = a%×b = a÷×b = a÷*b = "gl$, a %* b));
Line 494:
{{out}}
<pre>
a PLUS b = a+b = +468
a MINUS b = a-b = +242
a TIMES b = a*b = a×b = +40115
a DIV b = a/b = +3.141592920353982300884955752e +0
a OVER b = a%b = a÷b = +3
a MOD b = a%*b = a%×b = a÷×b = a÷*b = +16
a UP b = a**b = a↑b = +1.499007808785573768814747570e+288
</pre>
[[ALGOL 68R]] has a non-standard '/%:=' operator. This operator
is equivalent to the OVERAB operator of the revised report, except it delivers the remainder as a result.
So a '/:=' b sets a to the quotient of a%b and returns the remainder of a%b as a result (Note "%" is the division operator in Algol 68, not the modulo operator - it can also be written as OVER).
This operator must be "stropped" i.e. enclosed in single quotes. eg.
INT quotient:=355, remainder;
remainder := quotient '/%:=' 113;
Sets quotient to 3, remainder to 16.