Arithmetic/Integer: Difference between revisions
Content added Content deleted
No edit summary |
m (Added Eiffel (SmartEiffel 2.4)) |
||
Line 294: | Line 294: | ||
io.format("Remainder: ~p~n", [A % B]) |
io.format("Remainder: ~p~n", [A % B]) |
||
}</lang> |
}</lang> |
||
=={{header|Eiffel}}== |
|||
{{works with|SmartEiffel}} version 2.4 |
|||
In a file called main.e: |
|||
<lang eiffel>class MAIN |
|||
creation make |
|||
feature make is |
|||
local |
|||
a, b: REAL; |
|||
do |
|||
print("a = "); |
|||
io.read_real; |
|||
a := io.last_real; |
|||
print("b = "); |
|||
io.read_real; |
|||
b := io.last_real; |
|||
print("a + b = "); |
|||
io.put_real(a + b); |
|||
print("%Na - b = "); |
|||
io.put_real(a - b); |
|||
print("%Na * b = "); |
|||
io.put_real(a * b); |
|||
print("%Na / b = "); |
|||
io.put_real(a / b); |
|||
print("%Na %% b = "); |
|||
io.put_real(((a / b) - (a / b).floor) * b); |
|||
print("%Na ^ b = "); |
|||
io.put_real(a.pow(b)); |
|||
print("%N"); |
|||
end |
|||
end</lang> |
|||
Note that there actually is a builtin modulo operator (\\). However, it seems impossible to use that instruction with SmartEiffel. |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |