Sha256: 484c26d6ed0971787d07bbaf8379f3b85ab99ccad6be4aca7bffffbb8c3b83c4

Contents?: true

Size: 561 Bytes

Versions: 10

Compression:

Stored size: 561 Bytes

Contents

This demonstrates normal division (which produces rational numbers when possible), <CODE>div</CODE>, and <CODE>mod</CODE>.  <CODE>div</CODE> rounds toward negative infinity (defined as <CODE>floor[x/y]</CODE>).  <CODE>mod</CODE> uses the sign of the second number (defined as <CODE>x - y * floor[x/y]</CODE>).  All operators automatically produce big integers or exact rational numbers when necessary.

[a,b] = input["Enter numbers",["a","b"]]
ops=["+", "-", "*", "/", "div" ,"mod" ,"^"]
for op = ops
{
   str = "$a $op $b"
   println["$str = " + eval[str]]
}

Version data entries

10 entries across 7 versions & 1 rubygems

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