This article covers features introduced in SpiderMonkey 17

Compare double value and int32_t value.

Syntax

bool
JS_DoubleIsInt32(double d, int32_t *ip);
Name Type Description
d double A double value to compare
ip int32_t * A pointer to int32_t value to compare

Description

JS_DoubleIsInt32 returns true if d i sequal to *ip.

(comment from mozilla::NumberEqualsInt32) Casting a floating-point value that doesn't truncate to int32_t, to int32_t, induces undefined behavior. We should definitely fix this (bug 744965), but as apparently it "works" in practice, it's not a pressing concern now.

See Also