O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Math Functions: math.h

The math library contains extensions to the built-in data type handling for integer and floating-point numbers, as well as some useful trigonometric functions. There are also some complex math functions, but nothing concentrating on formulae processing or statistics.

There are two rounding functions that return an integer from a floating-point number, rounded up or down accordingly, expressed as a floating point. These functions are as follows:

ceil (<value>)Returns value, rounded up
floor (<value>)Returns value, rounded down

Note that rounding is to the next whole number (up or down) and that the resulting value is represented as a floating point (double), and not as an integer. It can, however, be cast back to an integer. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required