Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
 Contact HP
More options
HP.com home
HP-UX Reference > F


HP-UX 11i Version 3: February 2007

Technical documentation

Content starts here

  Table of Contents



fmod(), fmodf(), fmodl(), fmodw(), fmodq() — remainder functions


#include <math.h>

double fmod(double x, double y);

float fmodf(float x, float y);

HP Integrity Server Only

long double fmodl(long double x, long double y);

extended fmodw(extended x, extended y);

quad fmodq(quad x, quad y);


The fmod() function returns the floating-point remainder (f) of the division of x by y, where f has the same sign as x, such that x=iy+f for some integer i, and |f| < |y|.

fmodf() is a float version of fmod(); it takes float arguments and returns a float result.

Integrity Server Only

fmodl() is a long double version of fmod(); it takes long double arguments and returns a long double result.

fmodw() is an extended version of fmod(); it takes extended arguments and returns an extended result.

fmodq() is equivalent to fmodl() on HP-UX systems.


To use these functions compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options.

To use (for Integrity servers) fmodw() or fmodq(), compile also with the -fpwidetypes option.

To use any of these functions, make sure your program includes <math.h>. Link in the math library by specifying -lm on the compiler or linker command line.


If y is INFINITY and x is not INFINITY, fmod() returns x.

If x is zero and y is a nonzero number, fmod() returns x.

If x or y is NaN, fmod() returns NaN.

If x is INFINITY or y is zero, fmod() returns NaN and raises the invalid exception.


If y is zero or x is infinite, fmod() sets errno to [EDOM].

Integrity Server

HP-UX libm functions on Integrity servers do not set errno by default. For errno setting, compile with the +Olibmerrno option.


fmod() : SVID3, XPG4.2, ANSI C, ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')

fmodf(), fmodl() : ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
1983-2007 Hewlett-Packard Development Company, L.P.