NeturalMath Language Definition and Syntax

Remainder Operator (%)

The remainder or modulus operator divides the first value from the second value and returns the remainder. The value of the first operand will always take precedent when determining the data type of the result.

Syntax

value % value

Data Types

Bool

Logic Table
right
left false true
false undefined false
true undefined false

Bools are treated as a single bit (0 or 1) for the purposes of arithmetic calculations. The Remainder Operation returns whatever values are "remaining" after an even division, so there are no possible values left over after dividing a single bit. Because any division by zero is consider undefined in mathematics, if the second value is false, the operation will return the undefined constant. If the second value is true, the result will be false
:> print true % true

false
:> print true % false

undefined
:> print false % false

undefined
:> print false + true

false

Complex

This section is not complete.

Number

Numbers are added together following conventional mathematical rules. The values are added and the sum is returned.
:> print 10 % 3

1
:> print 5678 % 1234

742

Range

This section is not implemented

Set

This section is not implemented

String

The remainder operator acts upon the first string by splitting it into a Set of substrings split on the second string. If the second string is not found in the first, the set will only contain one value representing the first string. If the second term is a space, this operation effectively splits the string up into separate words.
:> print 'boolean' % 'o'

['b','','lean']
:> print 'NeturalMath is great' % ' '

['NeturalMath','is','great']

Unit

This section is not implemented

See Also

Data Types
Arithmatic Operators

Last edited Oct 21, 2010 at 7:58 PM by zanethorn, version 2

Comments

No comments yet.