Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

20.8.4 Remainder Functions

The functions in this section compute the remainder on division of two floating-point numbers. Each is a little different; pick the one that suits your problem.

— Function: double fmod (double numerator, double denominator)
— Function: float fmodf (float numerator, float denominator)
— Function: long double fmodl (long double numerator, long double denominator)

These functions compute the remainder from the division of numerator by denominator. Specifically, the return value is numerator - n * denominator, where n is the quotient of numerator divided by denominator, rounded towards zero to an integer. Thus, fmod (6.5, 2.3) returns 1.9, which is 6.5 minus 4.6.

The result has the same sign as the numerator and has magnitude less than the magnitude of the denominator.

If denominator is zero, fmod signals a domain error.

— Function: double drem (double numerator, double denominator)
— Function: float dremf (float numerator, float denominator)
— Function: long double dreml (long double numerator, long double denominator)

These functions are like fmod except that they rounds the internal quotient n to the nearest integer instead of towards zero to an integer. For example, drem (6.5, 2.3) returns -0.4, which is 6.5 minus 6.9.

The absolute value of the result is less than or equal to half the absolute value of the denominator. The difference between fmod (numerator, denominator) and drem (numerator, denominator) is always either denominator, minus denominator, or zero.

If denominator is zero, drem signals a domain error.

— Function: double remainder (double numerator, double denominator)
— Function: float remainderf (float numerator, float denominator)
— Function: long double remainderl (long double numerator, long double denominator)

This function is another name for drem.


 
 
  Published under the terms of the GNU General Public License Design by Interspire