7.2.1 Flonums
import: rhombus/flonum | package: rhombus-lib |
A flonum is a number that is represented using an IEEE 64-bit floating-point representation. A flonum is a plain number, so number operations like + work on flonums and mixtures of flonums with other numbers. In some cases, using functions and operators from rhombus/flonum can reduce run time by allowing flonum operations to more efficiently communicate intermediate results.
The functions exported by rhombus/flonum explicitly require flonum arguments and produce flonum results. They can produce different results from functions like math.sqrt, typically returning #nan when the result would not be a flonum, such as when a negative number is passed to math.sqrt.
Some operations, like +, statically specialize for performance when all arguments have static information for the Flonum annotation. There is no performance difference between that inferred specialization and these operators, and a conversion is inferred only when the result value is the same for unspecialized and flonum-specific operations.
operator | ||
| ||
| ||
operator | ||
| ||
| ||
operator | ||
| ||
| ||
operator | ||
| ||
| ||
operator | ||
| ||
| ||
operator | ||
|
operator | ||
| ||
| ||
operator | ||
| ||
| ||
operator | ||
| ||
| ||
operator | ||
| ||
| ||
operator | ||
| ||
| ||
operator | ||
|
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
Some related operations, such as math.sqrt, do not always produce flonum results for flonum arguments. In those cases, the corresponding function like flonum.sqrt produces #nan, instead. For example, flonum.sqrt(-1.0) is #nan instead of the complex number #{0.0+1.0i}.