pure/fenv

    Dark Mode
Search:
  Source   Edit

Floating-point environment. Handling of floating-point rounding and exceptions (overflow, division by zero, etc.). The types, vars and procs are bindings for the C standard library <fenv.h> header.

Types

Tfenv {.importc: "fenv_t", header: "<fenv.h>", final, pure.} = object
Represents the entire floating-point environment. The floating-point environment refers collectively to any floating-point status flags and control modes supported by the implementation.   Source   Edit
Tfexcept {.importc: "fexcept_t", header: "<fenv.h>", final, pure.} = object
Represents the floating-point status flags collectively, including any status the implementation associates with the flags. A floating-point status flag is a system variable whose value is set (but never cleared) when a floating-point exception is raised, which occurs as a side effect of exceptional floating-point arithmetic to provide auxiliary information. A floating-point control mode is a system variable whose value may be set by the user to affect the subsequent behavior of floating-point arithmetic.   Source   Edit

Vars

FE_ALL_EXCEPT: cint
bitwise OR of all supported exceptions   Source   Edit
FE_DFL_ENV: cint
macro of type pointer to fenv_t to be used as the argument to functions taking an argument of type fenv_t; in this case the default environment will be used   Source   Edit
FE_DIVBYZERO: cint
division by zero   Source   Edit
FE_DOWNWARD: cint
round toward -Inf   Source   Edit
FE_INEXACT: cint
inexact result   Source   Edit
FE_INVALID: cint
invalid operation   Source   Edit
FE_OVERFLOW: cint
result not representable due to overflow   Source   Edit
FE_TONEAREST: cint
round to nearest   Source   Edit
FE_TOWARDZERO: cint
round toward 0   Source   Edit
FE_UNDERFLOW: cint
result not representable due to underflow   Source   Edit
FE_UPWARD: cint
round toward +Inf   Source   Edit

Procs

proc feclearexcept(excepts: cint): cint {.importc, header: "<fenv.h>",
    ...raises: [], tags: [].}
Clear the supported exceptions represented by excepts.   Source   Edit
proc fegetenv(envp: ptr Tfenv): cint {.importc, header: "<fenv.h>", ...raises: [],
                                       tags: [].}
Store the current floating-point environment in the object pointed to by envp.   Source   Edit
proc fegetexceptflag(flagp: ptr Tfexcept; excepts: cint): cint {.importc,
    header: "<fenv.h>", ...raises: [], tags: [].}
Store implementation-defined representation of the exception flags indicated by excepts in the object pointed to by flagp.   Source   Edit
proc fegetround(): cint {.importc, header: "<fenv.h>", ...raises: [], tags: [].}
Get current rounding direction.   Source   Edit
proc feholdexcept(envp: ptr Tfenv): cint {.importc, header: "<fenv.h>",
    ...raises: [], tags: [].}
Save the current environment in the object pointed to by envp, clear exception flags and install a non-stop mode (if available) for all exceptions.   Source   Edit
proc feraiseexcept(excepts: cint): cint {.importc, header: "<fenv.h>",
    ...raises: [], tags: [].}
Raise the supported exceptions represented by excepts.   Source   Edit
proc fesetenv(a1: ptr Tfenv): cint {.importc, header: "<fenv.h>", ...raises: [],
                                     tags: [].}
Establish the floating-point environment represented by the object pointed to by envp.   Source   Edit
proc fesetexceptflag(flagp: ptr Tfexcept; excepts: cint): cint {.importc,
    header: "<fenv.h>", ...raises: [], tags: [].}
Set complete status for exceptions indicated by excepts according to the representation in the object pointed to by flagp.   Source   Edit
proc fesetround(roundingDirection: cint): cint {.importc, header: "<fenv.h>",
    ...raises: [], tags: [].}
Establish the rounding direction represented by roundingDirection.   Source   Edit
proc fetestexcept(excepts: cint): cint {.importc, header: "<fenv.h>",
    ...raises: [], tags: [].}
Determine which of subset of the exceptions specified by excepts are currently set.   Source   Edit
proc feupdateenv(envp: ptr Tfenv): cint {.importc, header: "<fenv.h>",
    ...raises: [], tags: [].}
Save current exceptions in temporary storage, install environment represented by object pointed to by envp and raise exceptions according to saved exceptions.   Source   Edit

Templates

template digits(T: typedesc[float32]): int
Number of decimal digits that can be represented in a 32-bit floating-point type without losing precision.   Source   Edit
template digits(T: typedesc[float64]): int
Number of decimal digits that can be represented in a 64-bit floating-point type without losing precision.   Source   Edit
template epsilon(T: typedesc[float32]): float32
The difference between 1.0 and the smallest number greater than 1.0 that can be represented in a 32-bit floating-point type.   Source   Edit
template epsilon(T: typedesc[float64]): float64
The difference between 1.0 and the smallest number greater than 1.0 that can be represented in a 64-bit floating-point type.   Source   Edit
template fpRadix(): int
The (integer) value of the radix used to represent any floating point type on the architecture used to build the program.   Source   Edit
template mantissaDigits(T: typedesc[float32]): int
Number of digits (in base floatingPointRadix) in the mantissa of 32-bit floating-point numbers.   Source   Edit
template mantissaDigits(T: typedesc[float64]): int
Number of digits (in base floatingPointRadix) in the mantissa of 64-bit floating-point numbers.   Source   Edit
template max10Exponent(T: typedesc[float32]): int
Maximum (positive) exponent in base 10 for 32-bit floating-point numbers.   Source   Edit
template max10Exponent(T: typedesc[float64]): int
Maximum (positive) exponent in base 10 for 64-bit floating-point numbers.   Source   Edit
template maxExponent(T: typedesc[float32]): int
Maximum (positive) exponent for 32-bit floating-point numbers.   Source   Edit
template maxExponent(T: typedesc[float64]): int
Maximum (positive) exponent for 64-bit floating-point numbers.   Source   Edit
template maximumPositiveValue(T: typedesc[float32]): float32
The largest positive number that can be represented in a 32-bit floating-point type.   Source   Edit
template maximumPositiveValue(T: typedesc[float64]): float64
The largest positive number that can be represented in a 64-bit floating-point type.   Source   Edit
template min10Exponent(T: typedesc[float32]): int
Minimum (negative) exponent in base 10 for 32-bit floating-point numbers.   Source   Edit
template min10Exponent(T: typedesc[float64]): int
Minimum (negative) exponent in base 10 for 64-bit floating-point numbers.   Source   Edit
template minExponent(T: typedesc[float32]): int
Minimum (negative) exponent for 32-bit floating-point numbers.   Source   Edit
template minExponent(T: typedesc[float64]): int
Minimum (negative) exponent for 64-bit floating-point numbers.   Source   Edit
template minimumPositiveValue(T: typedesc[float32]): float32
The smallest positive (nonzero) number that can be represented in a 32-bit floating-point type.   Source   Edit
template minimumPositiveValue(T: typedesc[float64]): float64
The smallest positive (nonzero) number that can be represented in a 64-bit floating-point type.   Source   Edit