mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-17 23:11:23 +00:00
Add javascript Number consts. (#1965)
* Add javascript Number consts. * Add tests
This commit is contained in:
committed by
Alex Crichton
parent
450c477197
commit
bb066e68a5
@ -18,6 +18,7 @@
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/js-sys/0.2")]
|
||||
|
||||
use std::f64;
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
|
||||
@ -1901,6 +1902,43 @@ extern "C" {
|
||||
pub fn value_of(this: &Number) -> f64;
|
||||
}
|
||||
|
||||
impl Number {
|
||||
/// The smallest interval between two representable numbers.
|
||||
///
|
||||
/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON)
|
||||
pub const EPSILON: f64 = f64::EPSILON;
|
||||
/// The maximum safe integer in JavaScript (2^53 - 1).
|
||||
///
|
||||
/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)
|
||||
pub const MAX_SAFE_INTEGER: f64 = 9007199254740991.0;
|
||||
/// The largest positive representable number.
|
||||
///
|
||||
/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE)
|
||||
pub const MAX_VALUE: f64 = f64::MAX;
|
||||
/// The minimum safe integer in JavaScript (-(2^53 - 1)).
|
||||
///
|
||||
/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER)
|
||||
pub const MIN_SAFE_INTEGER: f64 = -9007199254740991.0;
|
||||
/// The smallest positive representable number—that is, the positive number closest to zero
|
||||
/// (without actually being zero).
|
||||
///
|
||||
/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE)
|
||||
// Cannot use f64::MIN_POSITIVE since that is the smallest **normal** postitive number.
|
||||
pub const MIN_VALUE: f64 = 5E-324;
|
||||
/// Special "Not a Number" value.
|
||||
///
|
||||
/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN)
|
||||
pub const NAN: f64 = f64::NAN;
|
||||
/// Special value representing negative infinity. Returned on overflow.
|
||||
///
|
||||
/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY)
|
||||
pub const NEGATIVE_INFINITY: f64 = f64::NEG_INFINITY;
|
||||
/// Special value representing infinity. Returned on overflow.
|
||||
///
|
||||
/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)
|
||||
pub const POSITIVE_INFINITY: f64 = f64::INFINITY;
|
||||
}
|
||||
|
||||
macro_rules! number_from {
|
||||
($($x:ident)*) => ($(
|
||||
impl From<$x> for Number {
|
||||
|
Reference in New Issue
Block a user