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 {.importc, header: "<fenv.h>".}: cint
- bitwise OR of all supported exceptions Source Edit
FE_DFL_ENV {.importc, header: "<fenv.h>".}: 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 {.importc, header: "<fenv.h>".}: cint
- division by zero Source Edit
FE_DOWNWARD {.importc, header: "<fenv.h>".}: cint
- round toward -Inf Source Edit
FE_INEXACT {.importc, header: "<fenv.h>".}: cint
- inexact result Source Edit
FE_INVALID {.importc, header: "<fenv.h>".}: cint
- invalid operation Source Edit
FE_OVERFLOW {.importc, header: "<fenv.h>".}: cint
- result not representable due to overflow Source Edit
FE_TONEAREST {.importc, header: "<fenv.h>".}: cint
- round to nearest Source Edit
FE_TOWARDZERO {.importc, header: "<fenv.h>".}: cint
- round toward 0 Source Edit
FE_UNDERFLOW {.importc, header: "<fenv.h>".}: cint
- result not representable due to underflow Source Edit
Procs
proc feclearexcept(excepts: cint): cint {.importc, header: "<fenv.h>", ...raises: [], tags: [], forbids: [].}
- Clear the supported exceptions represented by excepts. Source Edit
proc fegetround(): cint {.importc, header: "<fenv.h>", ...raises: [], tags: [], forbids: [].}
- Get current rounding direction. Source Edit
proc feholdexcept(envp: ptr Tfenv): cint {.importc, header: "<fenv.h>", ...raises: [], tags: [], forbids: [].}
- 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: [], forbids: [].}
- Raise the supported exceptions represented by excepts. Source Edit
proc fesetround(roundingDirection: cint): cint {.importc, header: "<fenv.h>", ...raises: [], tags: [], forbids: [].}
- Establish the rounding direction represented by roundingDirection. Source Edit
proc fetestexcept(excepts: cint): cint {.importc, header: "<fenv.h>", ...raises: [], tags: [], forbids: [].}
- 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: [], forbids: [].}
- Save current exceptions in temporary storage, install environment represented by object pointed to by envp and raise exceptions according to saved exceptions. Source Edit