Skip to content

Commit

Permalink
address comment + avoid exporting c_isnan
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Dec 9, 2020
1 parent 69235b4 commit 54d6e80
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/pure/math.nim
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ import bitops, fenv
when defined(c) or defined(cpp):
#[
Low level wrappers around C math functions.
Consider moving this to a dedicated `std/cmath`.
Consider moving this and other direct c wrappers to a dedicated `std/cmath`,
refs https://github.com/nim-lang/RFCs/issues/92#issuecomment-735328291
]#
proc c_isnan*(x: float): bool {.importc: "isnan", header: "<math.h>".}
proc c_isnan(x: float): bool {.importc: "isnan", header: "<math.h>".}
# a generic like `x: SomeFloat` might work too if this is implemented via a C macro.

func binom*(n, k: int): int =
Expand Down Expand Up @@ -148,6 +149,9 @@ func isNaN*(x: SomeFloat): bool {.inline, since: (1,5,1).} =
doAssert NaN.isNaN
doAssert not Inf.isNaN
doAssert isNaN(Inf - Inf)
doAssert not isNan(3.1415926)
doAssert not isNan(0'f32)

template fn: untyped = result = x != x
when nimvm: fn()
else:
Expand Down

0 comments on commit 54d6e80

Please sign in to comment.