updating oE remainder

Roundings and Remainders


<built-in> function remainder(object dividend, object divisor) 

computes the remainder of the division of two objects using truncated division.

  1. dividend : any Euphoria object.
  2. divisor : any Euphoria object.

An object, the shape of which depends on dividend's and divisor's. For two atoms, this is the remainder of dividing dividend by divisor, with dividend's sign.

  1. If any atom in divisor is 0, this is an error condition as it amounts to an attempt to divide by zero.
  2. If both dividend and divisor are sequences, they must be the same length as each other.
  • There is a integer N such that dividend = N * divisor + result.
  • The result has the sign of dividend and lesser magnitude than divisor.
  • The result has the same sign as the dividend.
  • This differs from mod in that when the operands' signs are different this function rounds dividend/divisior towards zero whereas mod rounds away from zero.

The arguments to this function may be atoms or sequences. The rules for operations on sequences apply, and determine the shape of the returned object.

Example 1:
a = remainder(9, 4) 
-- a is 1 
Example 2:
s = remainder({81, -3.5, -9, 5.5}, {8, -1.7, 2, -4}) 
-- s is {1, -0.1, -1, 1.5} 
Example 3:
s = remainder({17, 12, 34}, 16) 
-- s is {1, 12, 2} 
Example 4:
s = remainder(16, {2, 3, 5}) 
-- s is {0, 1, 1} 
See Also:

mod, Relational operators, Operations on sequences

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu