| |||
Home > Floating-point Support > The software floating-point library, fplib > Arithmetic on numbers in a particular format |
The routines in Table 5.1 perform arithmetic on numbers in a particular format. Arguments and results are always in the same format.
Table 5.1. Arithmetic routines
Function | Argument types | Result type | Operation |
---|---|---|---|
_fadd | 2 float | float | Return x plus y |
_fsub | 2 float | float | Return x minus y |
_frsb | 2 float | float | Return y minus x |
_fmul | 2 float | float | Return x times y |
_fdiv | 2 float | float | Return x divided by y |
_frdiv | 2 float | float | Return y divided by x |
_frem | 2 float | float | Return remainder^{[1]} of x by y |
_frnd | float | float | Return x rounded to an integer^{[2]} |
_fsqrt | float | float | Return square root of x |
_dadd | 2 double | double | Return x plus y |
_dsub | 2 double | double | Return x minus y |
_drsb | 2 double | double | Return y minus x |
_dmul | 2 double | double | Return x times y |
_ddiv | 2 double | double | Return x divided by y |
_drdiv | 2 double | double | Return y divided by x |
_drem | 2 double | double | Return remainder^{a} of x by y |
_drnd | double | double | Return x rounded to an integer^{b} |
_dsqrt | double | double | Return square root of x |
^{[1] }Functions that
perform the IEEE 754 remainder operation. This is defined to take
two numbers, x and y,
and return a number z such that z
= x – n * y, where n is an integer.
To return an exactly correct result, n is chosen
so that z is no bigger than half of x (so
that z might be negative even if both x and y are
positive). The IEEE 754 remainder function is not the same as the operation
performed by the C library function ^{[2] }Functions
that perform the IEEE 754 round-to-integer operation. This takes
a number and rounds it to an integer (in accordance with the current
rounding mode), but returns that integer in the floating-point number
format rather than as a C int variable. To convert
a number to an int variable, you must use the |