Jump to content

Arithmetic/Integer: Difference between revisions

m (→‎{{header|dc}}: 'p' does not pop the stack; use 'sz' to pop and discard the top value.)
Line 623:
a - b = ${a} - ${b} = ${a - b}
a * b = ${a} * ${b} = ${a * b}
a / b = ${a} / ${b} = ${a / b} !!! Converts to floating point!
(int)(a / b) = (int)(${a} / ${b}) = ${(int)(a / b)} !!! Truncates downward after the fact
a.intdiv(b) = ${a}.intdiv(${b}) = ${a.intdiv(b)} !!! Behaves as if truncating downward, actual implementation varies
a % b = ${a} % ${b} = ${a % b}
 
Line 640:
a - b = 5 - 3 = 2
a * b = 5 * 3 = 15
a / b = 5 / 3 = 1.6666666667 !!! Converts to floating point!
(int)(a / b) = (int)(5 / 3) = 1 !!! Truncates downward after the fact
a.intdiv(b) = 5.intdiv(3) = 1 !!! Behaves as if truncating downward, actual implementation varies
a % b = 5 % 3 = 2
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.