Arithmetic/Integer: Difference between revisions

Content added Content deleted
No edit summary
Line 798: Line 798:


=={{header|Elena}}==
=={{header|Elena}}==
<lang elena>#define std'basic'*.
<lang elena>#define system.
#define math'* = std'math'*.
#define extensions'io.
#define extensions'math.


#symbol Program =
// --- Program ---

#symbol program =
[
[
#var a := 'program'input >> Integer.
#var a := consoleEx readLine:(Integer new).
#var b := 'program'input >> Integer.
#var b := consoleEx readLine:(Integer new).
'program'output << a << " + " << b << " = " << a + b << "%n".
consoleEx << a << " + " << b << " = " << a + b << "%n".
'program'output << a << " - " << b << " = " << a - b << "%n".
consoleEx << a << " - " << b << " = " << a - b << "%n".
'program'output << a << " * " << b << " = " << a * b << "%n".
consoleEx << a << " * " << b << " = " << a * b << "%n".
'program'output << a << " / " << b << " = " << a / b << "%n". // truncates towards 0
consoleEx << a << " / " << b << " = " << a / b << "%n". // truncates towards 0
'program'output << a << " %% " << b << " = " << a~math'eops math'modulus:b << "%n". // matches sign of first operand
consoleEx << a << " %% " << b << " = " << (modulus:a:b) << "%n". // matches sign of first operand
].</lang>
].</lang>