|
1 | 1 | -- | Functions for working with PureScripts builtin `Number` type.
|
2 | 2 | module Data.Number
|
3 | 3 | ( fromString
|
| 4 | + , epsilon |
4 | 5 | , nan
|
5 | 6 | , isNaN
|
6 | 7 | , infinity
|
| 8 | + , negativeInfinity |
7 | 9 | , isFinite
|
| 10 | + , minValue |
| 11 | + , maxValue |
8 | 12 | ) where
|
9 | 13 |
|
10 | 14 | import Data.Function.Uncurried (Fn4, runFn4)
|
11 | 15 | import Data.Maybe (Maybe(..))
|
12 | 16 |
|
| 17 | +-- | The `Number` value for the magnitude of the difference between 1 and |
| 18 | +-- | the smallest value greater than 1 that is representable as a |
| 19 | +-- | `Number` value, which is approximately |
| 20 | +-- | 2.2204460492503130808472633361816 × 10⁻¹⁶ |
| 21 | +foreign import epsilon :: Number |
| 22 | + |
13 | 23 | -- | Not a number (NaN)
|
14 | 24 | foreign import nan :: Number
|
15 | 25 |
|
16 | 26 | -- | Test whether a number is NaN
|
17 | 27 | foreign import isNaN :: Number -> Boolean
|
18 | 28 |
|
19 |
| --- | Positive infinity |
| 29 | +-- | Positive infinity, +∞𝔽 |
20 | 30 | foreign import infinity :: Number
|
21 | 31 |
|
| 32 | +-- | Negative inifinity, -∞𝔽 |
| 33 | +foreign import negativeInfinity :: Number |
| 34 | + |
22 | 35 | -- | Test whether a number is finite
|
23 | 36 | foreign import isFinite :: Number -> Boolean
|
24 | 37 |
|
@@ -53,3 +66,11 @@ fromString :: String -> Maybe Number
|
53 | 66 | fromString str = runFn4 fromStringImpl str isFinite Just Nothing
|
54 | 67 |
|
55 | 68 | foreign import fromStringImpl :: Fn4 String (Number -> Boolean) (forall a. a -> Maybe a) (forall a. Maybe a) (Maybe Number)
|
| 69 | + |
| 70 | +-- | The largest positive finite value of the `Number` type, which is |
| 71 | +-- | approximately 1.7976931348623157 × 10³⁰⁸ |
| 72 | +foreign import maxValue :: Number |
| 73 | + |
| 74 | +-- | The smallest positive value of the `Number` type, which is |
| 75 | +-- | approximately 5 × 10⁻³²⁴ |
| 76 | +foreign import minValue :: Number |
0 commit comments