Introduction to C / C++ Programming






Float, Double, and Long Double Library Functions

By default the math library functions for sine, cosine, logarithms, etc. take doubles as their arguments and return doubles for their results.  If you pass them different data types, they will automatically and silently convert to and from doubles.

Starting with the C99 standard, however, additional functions are defined for floats and long doubles.  For example, in addition to “double cos( double );”, there is now “float cosf( float );” and “long double cosl( long double );”  For further details go to .  If you click on an individual function, such as cos( ), there are tabs to select the C99 standard.

In order to use the C99 standard, you may need to tell your development environment.  In Dev C++ the way to do this is to go to the Project menu and select “project options”, and then select the “Parameters” tab.  In the column labeled “C++ compiler” enter the string “-std=c99”.