Sha256: 35be79b6063b4dccfea5e876d90c63d2b21e272df972023bef46abbf3317bfa8

Contents?: true

Size: 698 Bytes

Versions: 10

Compression:

Stored size: 698 Bytes

Contents

In Wren the quotient operator '/' does not round but, when the ''floor'' method is applied to the result, it rounds to the lower integer.

The sign of the remainder operator '%' matches the sign of the first operand.
import "io" for Stdin, Stdout
System.write("first number:     ")
Stdout.flush()
var a = Num.fromString(Stdin.readLine())
System.write("second number:    ")
Stdout.flush()
var b = Num.fromString(Stdin.readLine())
System.print("sum:              %(a + b)")
System.print("difference:       %(a - b)")
System.print("product:          %(a * b)")
System.print("integer quotient: %((a / b).floor)")
System.print("remainder:        %(a % b)")
System.print("exponentiation:   %(a.pow(b))")

Version data entries

10 entries across 7 versions & 1 rubygems

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