Arithmetic/Integer: Difference between revisions

Add Genie
(Add Genie)
Line 1,797:
CloseStream(f);
end;</lang>
 
=={{header|Genie}}==
Note: Using ''init:int'' and the ''return'' from the init block was introduced in release 0.43.92, February 2019.
 
<lang genie>[indent=4]
/*
Arithmethic/Integer, in Genie
valac arithmethic-integer.gs
*/
 
init:int
a:int = 0
b:int = 0
if args.length > 2 do b = int.parse(args[2])
if args.length > 1 do a = int.parse(args[1])
 
print @"a+b: $a plus $b is $(a+b)"
print @"a-b: $a minus $b is $(a-b)"
print @"a*b: $a times $b is $(a*b)"
print @"a/b: $a by $b quotient is $(a/b) (rounded mode is TRUNCATION)"
print @"a%b: $a by $b remainder is $(a%b) (sign matches first operand)"
 
print "\nGenie does not include a raise to power operator"
 
return 0</lang>
 
{{out}}
<pre>prompt$ valac arithmetic-integer.gs
prompt$ ./arithmetic-integer -390 100
a+b: -390 plus 100 is -290
a-b: -390 minus 100 is -490
a*b: -390 times 100 is -39000
a/b: -390 by 100 quotient is -3 (rounded mode is TRUNCATION)
a%b: -390 by 100 remainder is -90 (sign matches first operand)
 
Genie does not include a raise to power operator</pre>
 
=={{header|GEORGE}}==
Anonymous user