Link the <fenv.h> header (#16597)
This commit is contained in:
parent
c04f305bf7
commit
2c2baa9fad
2 changed files with 6 additions and 5 deletions
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
## Floating-point environment. Handling of floating-point rounding and
|
## Floating-point environment. Handling of floating-point rounding and
|
||||||
## exceptions (overflow, division by zero, etc.).
|
## exceptions (overflow, division by zero, etc.).
|
||||||
|
## The types, vars and procs are bindings for the C standard library
|
||||||
|
## [<fenv.h>](https://en.cppreference.com/w/c/numeric/fenv) header.
|
||||||
|
|
||||||
when defined(Posix) and not defined(genode):
|
when defined(Posix) and not defined(genode):
|
||||||
{.passl: "-lm".}
|
{.passl: "-lm".}
|
||||||
|
|
@ -35,8 +37,8 @@ var
|
||||||
FE_UPWARD* {.importc, header: "<fenv.h>".}: cint
|
FE_UPWARD* {.importc, header: "<fenv.h>".}: cint
|
||||||
## round toward +Inf
|
## round toward +Inf
|
||||||
FE_DFL_ENV* {.importc, header: "<fenv.h>".}: cint
|
FE_DFL_ENV* {.importc, header: "<fenv.h>".}: cint
|
||||||
## macro of type pointer to fenv_t to be used as the argument
|
## macro of type pointer to `fenv_t` to be used as the argument
|
||||||
## to functions taking an argument of type fenv_t; in this
|
## to functions taking an argument of type `fenv_t`; in this
|
||||||
## case the default environment will be used
|
## case the default environment will be used
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import fenv
|
import std/fenv
|
||||||
|
|
||||||
|
|
||||||
func is_significant(x: float): bool =
|
func is_significant(x: float): bool =
|
||||||
if x > minimumPositiveValue(float) and x < maximumPositiveValue(float): true
|
x > minimumPositiveValue(float) and x < maximumPositiveValue(float)
|
||||||
else: false
|
|
||||||
|
|
||||||
doAssert is_significant(10.0)
|
doAssert is_significant(10.0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue