This repository was archived by the owner on Dec 18, 2020. It is now read-only.
File tree 3 files changed +19
-19
lines changed
3 files changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -7,20 +7,20 @@ exports.unsafeStringify = function (x) {
7
7
return JSON . stringify ( x ) ;
8
8
} ;
9
9
10
- exports . unsafeToFixed = function ( n ) {
11
- return function ( digits ) {
10
+ exports . unsafeToFixed = function ( digits ) {
11
+ return function ( n ) {
12
12
return n . toFixed ( digits ) ;
13
13
} ;
14
14
} ;
15
15
16
- exports . unsafeToExponential = function ( n ) {
17
- return function ( digits ) {
16
+ exports . unsafeToExponential = function ( digits ) {
17
+ return function ( n ) {
18
18
return n . toExponential ( digits ) ;
19
19
} ;
20
20
} ;
21
21
22
- exports . unsafeToPrecision = function ( n ) {
23
- return function ( digits ) {
22
+ exports . unsafeToPrecision = function ( digits ) {
23
+ return function ( n ) {
24
24
return n . toPrecision ( digits ) ;
25
25
} ;
26
26
} ;
Original file line number Diff line number Diff line change @@ -7,16 +7,16 @@ foreign import unsafeStringify :: forall a. a -> String
7
7
-- | Formats Number as a String with limited number of digits after the dot
8
8
-- | May throw RangeError if the number of digits is not within the allowed range
9
9
-- | (standard precision range is 0 to 20, but implementations may change it)
10
- foreign import unsafeToFixed :: Number -> Int -> String
10
+ foreign import unsafeToFixed :: Int -> Number -> String
11
11
12
12
-- | Formats Number as String in exponential notation limiting number of digits
13
13
-- | after the decimal dot.
14
14
-- | May throw RangeError if the number of digits is not within the allowed range
15
15
-- | (standard precision range is 0 to 20, but implementations may change it)
16
- foreign import unsafeToExponential :: Number -> Int -> String
16
+ foreign import unsafeToExponential :: Int -> Number -> String
17
17
18
18
-- | Formats Number as String in fixed-point or exponential notation rounded
19
19
-- | to specified number of significant digits.
20
20
-- | May throw RangeError if the number of digits is not within the allowed range
21
21
-- | (standard precision range is 0 to 100, but implementations may change it)
22
- foreign import unsafeToPrecision :: Number -> Int -> String
22
+ foreign import unsafeToPrecision :: Int -> Number -> String
Original file line number Diff line number Diff line change @@ -45,19 +45,19 @@ main = do
45
45
assert $ readFloat " 3.5" == 3.5
46
46
47
47
-- note the rounding
48
- log $ " unsafeToFixed " <> (show num) <> " 1 == \" 12345.7\" "
49
- assert $ unsafeToFixed num 1 == " 12345.7"
48
+ log $ " unsafeToFixed 1 " <> (show num) <> " == \" 12345.7\" "
49
+ assert $ unsafeToFixed 1 num == " 12345.7"
50
50
51
51
-- padded with zeros
52
- log $ " unsafeToFixed " <> (show num) <> " 6 == \" 12345.678900\" "
53
- assert $ unsafeToFixed num 6 == " 12345.678900"
52
+ log $ " unsafeToFixed 6 " <> (show num) <> " == \" 12345.678900\" "
53
+ assert $ unsafeToFixed 6 num == " 12345.678900"
54
54
55
- log $ " unsafeToExponential " <> (show num) <> " 4 == \" 1.2346e+4\" "
56
- assert $ unsafeToExponential num 4 == " 1.2346e+4"
55
+ log $ " unsafeToExponential 4 " <> (show num) <> " == \" 1.2346e+4\" "
56
+ assert $ unsafeToExponential 4 num == " 1.2346e+4"
57
57
58
- log $ " unsafeToPrecision " <> (show num) <> " 3 == \" 1.23e+4\" "
59
- assert $ unsafeToPrecision num 3 == " 1.23e+4"
58
+ log $ " unsafeToPrecision 3 " <> (show num) <> " == \" 1.23e+4\" "
59
+ assert $ unsafeToPrecision 3 num == " 1.23e+4"
60
60
61
- log $ " unsafeToPrecision " <> (show num) <> " 6 == \" 12345.7\" "
62
- assert $ unsafeToPrecision num 6 == " 12345.7"
61
+ log $ " unsafeToPrecision 6 " <> (show num) <> " == \" 12345.7\" "
62
+ assert $ unsafeToPrecision 6 num == " 12345.7"
63
63
You can’t perform that action at this time.
0 commit comments