|
|
|
@ -402,7 +402,20 @@ impl Number {
|
|
|
|
|
make_builtin_fn(Self::to_string, "toString", &prototype, 1); |
|
|
|
|
make_builtin_fn(Self::value_of, "valueOf", &prototype, 0); |
|
|
|
|
|
|
|
|
|
make_constructor_fn("Number", 1, Self::make_number, global, prototype, true) |
|
|
|
|
let number = make_constructor_fn("Number", 1, Self::make_number, global, prototype, true); |
|
|
|
|
|
|
|
|
|
// Constants from:
|
|
|
|
|
// https://tc39.es/ecma262/#sec-properties-of-the-number-constructor
|
|
|
|
|
number.set_field("EPSILON", Value::from(std::f64::EPSILON)); |
|
|
|
|
number.set_field("MAX_SAFE_INTEGER", Value::from(9_007_199_254_740_991_f64)); |
|
|
|
|
number.set_field("MIN_SAFE_INTEGER", Value::from(-9_007_199_254_740_991_f64)); |
|
|
|
|
number.set_field("MAX_VALUE", Value::from(std::f64::MAX)); |
|
|
|
|
number.set_field("MIN_VALUE", Value::from(std::f64::MIN)); |
|
|
|
|
number.set_field("NEGATIVE_INFINITY", Value::from(f64::NEG_INFINITY)); |
|
|
|
|
number.set_field("POSITIVE_INFINITY", Value::from(f64::INFINITY)); |
|
|
|
|
number.set_field("NaN", Value::from(f64::NAN)); |
|
|
|
|
|
|
|
|
|
number |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Initialise the `Number` object on the global object.
|
|
|
|
|