|
18 | 18 |
|
19 | 19 | #![doc(html_root_url = "https://docs.rs/js-sys/0.2")]
|
20 | 20 |
|
| 21 | +use std::f64; |
21 | 22 | use std::fmt;
|
22 | 23 | use std::mem;
|
23 | 24 |
|
@@ -1901,6 +1902,43 @@ extern "C" {
|
1901 | 1902 | pub fn value_of(this: &Number) -> f64;
|
1902 | 1903 | }
|
1903 | 1904 |
|
| 1905 | +impl Number { |
| 1906 | + /// The smallest interval between two representable numbers. |
| 1907 | + /// |
| 1908 | + /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON) |
| 1909 | + pub const EPSILON: f64 = f64::EPSILON; |
| 1910 | + /// The maximum safe integer in JavaScript (2^53 - 1). |
| 1911 | + /// |
| 1912 | + /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER) |
| 1913 | + pub const MAX_SAFE_INTEGER: f64 = 9007199254740991.0; |
| 1914 | + /// The largest positive representable number. |
| 1915 | + /// |
| 1916 | + /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE) |
| 1917 | + pub const MAX_VALUE: f64 = f64::MAX; |
| 1918 | + /// The minimum safe integer in JavaScript (-(2^53 - 1)). |
| 1919 | + /// |
| 1920 | + /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER) |
| 1921 | + pub const MIN_SAFE_INTEGER: f64 = -9007199254740991.0; |
| 1922 | + /// The smallest positive representable number—that is, the positive number closest to zero |
| 1923 | + /// (without actually being zero). |
| 1924 | + /// |
| 1925 | + /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE) |
| 1926 | + // Cannot use f64::MIN_POSITIVE since that is the smallest **normal** postitive number. |
| 1927 | + pub const MIN_VALUE: f64 = 5E-324; |
| 1928 | + /// Special "Not a Number" value. |
| 1929 | + /// |
| 1930 | + /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN) |
| 1931 | + pub const NAN: f64 = f64::NAN; |
| 1932 | + /// Special value representing negative infinity. Returned on overflow. |
| 1933 | + /// |
| 1934 | + /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY) |
| 1935 | + pub const NEGATIVE_INFINITY: f64 = f64::NEG_INFINITY; |
| 1936 | + /// Special value representing infinity. Returned on overflow. |
| 1937 | + /// |
| 1938 | + /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY) |
| 1939 | + pub const POSITIVE_INFINITY: f64 = f64::INFINITY; |
| 1940 | +} |
| 1941 | + |
1904 | 1942 | macro_rules! number_from {
|
1905 | 1943 | ($($x:ident)*) => ($(
|
1906 | 1944 | impl From<$x> for Number {
|
|
0 commit comments