Arithmetic/Integer: Difference between revisions

no edit summary
(REXX added)
No edit summary
Line 502:
}
}</lang>
 
=={{header|HicEst}}==
All numeric is 8-byte-float. Conversions are by INT, NINT, FLOOR, CEILING, or Formatted IO
<lang hicest>DLG(Edit=A, Edit=B, TItle='Enter numeric A and B')
WRITE(Name) A, B
WRITE() ' A + B = ', A + B
WRITE() ' A - B = ', A - B
WRITE() ' A * B = ', A * B
WRITE() ' A / B = ', A / B ! no truncation
WRITE() 'truncate A / B = ', INT(A / B) ! truncates towards 0
WRITE() 'round next A / B = ', NINT(A / B) ! truncates towards next integer
WRITE() 'round down A / B = ', FLOOR(A / B) ! truncates towards minus infinity
WRITE() 'round up A / B = ', CEILING(A / B) ! truncates towards plus infinity
WRITE() 'remainder of A / B = ', MOD(A, B) ! same sign as A
WRITE() 'A to the power of B = ', A ^ B
WRITE() 'A to the power of B = ', A ** B</lang>
<lang hicest>A=5; B=-4;
A + B = 1
A - B = 9
A * B = -20
A / B = -1.25
truncate A / B = -1
round next A / B = -1
round down A / B = -2
round up A / B = -1
remainder of A / B = 1
A to the power of B = 16E-4
A to the power of B = 16E-4 </lang>
 
=={{header|J}}==
Anonymous user