From 54d6e80fd339638a8f0e2fcee6ccfc7d13a279e3 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Tue, 8 Dec 2020 18:27:14 -0800 Subject: [PATCH] address comment + avoid exporting c_isnan --- lib/pure/math.nim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pure/math.nim b/lib/pure/math.nim index 6182d625cebbd..cbf8129aa6805 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -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: "".} + proc c_isnan(x: float): bool {.importc: "isnan", header: "".} # a generic like `x: SomeFloat` might work too if this is implemented via a C macro. func binom*(n, k: int): int = @@ -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: