Sha256: 2e6a161d899d67c062226599365c3ba5969dc123a8256aa9e27d596c4cf84f52

Contents?: true

Size: 692 Bytes

Versions: 10

Compression:

Stored size: 692 Bytes

Contents

Note: Using ''init:int'' and the ''return'' from the init block was introduced in release 0.43.92, February 2019.

[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

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/genie.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/genie.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/genie.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/genie.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/genie.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/genie.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/genie.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/genie.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/genie.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/genie.txt