Sha256: 6aebd5dac7ec9db4aaed483509610a8e0e4f9dd04e35d84ac24bf3013072bb0e

Contents?: true

Size: 891 Bytes

Versions: 10

Compression:

Stored size: 891 Bytes

Contents

Example tested with Q'Nial7.

Define new operator using an atlas of operators:
     arithmetic is OP A B{[first,last,+,-,*,quotient,mod,power] A B}

Test new operator:
     -23 arithmetic 7
-23 7 -16 -30 -161 -4 5 -3404825447

Negative divisors are not accepted for integer quotient <code>quotient</code> or remainder <code>mod</code>, and in both cases the result is an error with the message <code>?negative divisor</code>.

For <code>quotient</code>, if the divisor <code>B</code> is zero, the result is zero.

For <code>mod</code>, if the divisor <code>B</code> is zero, the result is <code>A</code>.

The quotient on division by a positive integer <code>B</code> is always an integer on the same side of the origin as <code>A</code>.

Nial definition of <code>quotient</code>:

A quotient B =f=  floor (A / B)

<code>floor</code> rounds towards negative infinity (next lower integer).

Version data entries

10 entries across 7 versions & 1 rubygems

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