Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

fmod(3)  —  Subroutines

NAME

fmod, drem, remainder − Computes the Modulo Remainder, and a floating-point remainder

LIBRARY

Math Library (libm.a)

SYNOPSIS

#include <math.h>

doublefmod       (double x, double y);
floatfmodf      (float  x, float  y);
doubledrem       (double x, double y);
floatdremf      (float  x, float  y);
doubleremainder  (double x, double y);
floatremainderf (float  x, float  y);

DESCRIPTION

fmod() and fmodf() return the remainder  r = x - n∗y, where n = trunc(x/y).  The result has the same sign as x and magnitude less than the magnitude of y. 

drem(), dremf(), remainder(), and remainderf() return the remainder  r = x - n∗y, where n = rint(x/y).  Additionally if |n-x/y|=1/2, then n is even.  Consequently the remainder is computed exactly and |r| is less than or equal to |y|/2. 

drem(), dremf(), remainder(), and remainderf() are equivalent functions. 

Function Exceptional Argument Routine Behavior
fmod(),  fmodf() x = infinity invalid argument
fmod(),  fmodf() y = 0 invalid argument
drem(),  dremf() x = infinity invalid argument
drem(),  dremf() y = 0 invalid argument
remainder() x = infinity invalid argument
remainderf() x = infinity invalid argument
remainder() y = 0 invalid argument
remainderf() y = 0 invalid argument

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026