mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-12 06:38:45 +01:00
Extending 'sign' method to handle also "equal to zero" case.
This commit is contained in:
@ -906,7 +906,17 @@ DEF_PRIMITIVE(num_rad)
|
||||
|
||||
DEF_PRIMITIVE(num_sign)
|
||||
{
|
||||
RETURN_NUM(AS_NUM(args[0]) >= 0.0 ? 1 : -1);
|
||||
double num = AS_NUM(args[0]);
|
||||
double sign;
|
||||
if (num > 0) {
|
||||
sign = 1;
|
||||
} else
|
||||
if (num < 0) {
|
||||
sign = -1;
|
||||
} else {
|
||||
sign = 0;
|
||||
}
|
||||
RETURN_NUM(sign);
|
||||
}
|
||||
|
||||
DEF_PRIMITIVE(num_sin)
|
||||
|
||||
Reference in New Issue
Block a user