Name

mod, fmod — returns the modulus of its arguments

Synopsis

mod( dividend integer,
  divisor integer);
 
fmod( dividend double precision,
  divisor double precision);
 

Description

mod returns the modulus (i.e. remainder) of the integer division dividend / divisor. If the divisor is zero the SQL error 22012 "Division by zero" is generated.

mod(35,3)			-> 2
mod(35,-3)			-> 2
mod(-35,3)			-> -2
mod(-35,-3)			-> -2
mod(3,35)			-> 3
mod(0,7)			-> 0
mod(60,3)			-> 0
    

fmod is the floating-point counterpart of mod. It returns the IEEE 754 remainder of dividend / divisor, with the same sign as dividend. The result is computed as dividend - n * divisor, where n is the value dividend / divisor truncated toward zero.

fmod(5.5, 2.0)			-> 1.5
fmod(-5.5, 2.0)			-> -1.5
fmod(5.5, -2.0)			-> 1.5
    

See also remainder for the round-to-even IEEE 754 variant.


© 1992 - OpenLink Software. All rights reserved.

Making Technology Work for You®