11module Data.Float32
2- ( Float32 , fromNumber , fromNumber' , toNumber
2+ ( Float32
3+ , fromNumber
4+ , fromNumber'
5+ , toNumber
36 ) where
47
58import Prelude
6- ( class Eq , class Ord , class Show , class Semiring , class Ring , class Bounded , class EuclideanRing
7- , class CommutativeRing , class DivisionRing
8- , top , bottom , (==), (||))
9- import Data.Maybe (Maybe (..))
9+ ( class Eq
10+ , class Ord
11+ , class Show
12+ , class Semiring
13+ , class Ring
14+ , class Bounded
15+ , class EuclideanRing
16+ , class CommutativeRing
17+ , class DivisionRing
18+ , top
19+ , bottom
20+ , (==)
21+ , (||)
22+ )
23+ import Data.Maybe (Maybe (..))
1024
1125-- | [32-bit single-precision floating-point](https://en.wikipedia.org/wiki/Single-precision_floating-point_format)
1226-- | number.
@@ -24,17 +38,17 @@ instance boundedFloat32 :: Bounded Float32 where
2438 top = float32Top
2539 bottom = float32Bottom
2640
27-
2841foreign import float32Top :: Float32
2942foreign import float32Bottom :: Float32
3043
31-
3244-- | Uses `Math.fround()` to convert to a `Float32`.
3345-- | Returns `Nothing` when outside the range.
3446fromNumber :: Number -> Maybe Float32
3547fromNumber x =
36- let r = fromNumberImpl x
37- in if r == top || r == bottom then Nothing else Just (Float32 r)
48+ let
49+ r = fromNumberImpl x
50+ in
51+ if r == top || r == bottom then Nothing else Just (Float32 r)
3852
3953-- | Uses `Math.fround()` to convert to a `Float32`.
4054-- | Returns *0.0* when outside the range.
@@ -43,7 +57,6 @@ fromNumber' x = case fromNumber x of
4357 Nothing -> Float32 0.0
4458 Just y -> y
4559
46-
4760foreign import fromNumberImpl :: Number -> Number
4861
4962toNumber :: Float32 -> Number
0 commit comments