Go to main content
Oracle® Developer Studio 12.6: Numerical Computation Guide

Exit Print View

Updated: July 2017
 
 

3.3 Single, Double, and Extended/Quadruple Precision

Most numerical functions are available in single, double, and extended (x86) or quadruple precision. Examples of calling different precision versions of various functions from different languages are shown in Table 17.

Table 17  Calling Single, Double, and Extended/Quadruple Functions
Language
Single
Double
Extended/Quadruple
C, C++
#include <math.h> float x,y,z; x = sinf(y); x = fmodf(y,z); #include <sunmath.h> float x; x = max_normalf(); x = r_addran_();
#include <math.h> double x,y,z; x = sin(y); x = fmod(y,z); #include <sunmath.h> double x; x = max_normal(); x = d_addran_();
#include <math.h> long double x,y,z; x = sinl(y); x = fmodl(y,z); #include <sunmath.h> long double x; x = max_normall();
Fortran
REAL x,y,z x = sin(y) x = r_fmod(y,z) x = r_max_normal() x = r_addran()
REAL*8 x,y,z x = sin(y) x = d_fmod(y,z) x = d_max_normal() x = d_addran()
REAL*16 x,y,z x = sin(y) x = q_fmod(y,z) x = q_max_normal()

In C, names of single precision functions are formed by appending f to the double precision name, and names of extended or quadruple precision functions are formed by adding l. Because Fortran calling conventions differ, libsunmath provides r_…, d_…, and q_… functions for single, double, and quadruple precision, respectively. Fortran intrinsic functions can be called by the generic name for all three precisions.

Not all functions have q_… versions. Refer to math.h and sunmath.h for names and definitions of libm and libsunmath functions.

In Fortran programs, remember to declare r_… functions as real, d_… functions as double precision, and q_… functions as REAL*16. Otherwise, type mismatches might result.


Note -  Oracle Developer Studio Fortran does not support extended double precision.