This repository was archived by the owner on Dec 18, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +19
-19
lines changed Expand file tree Collapse file tree 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) {
77 return JSON . stringify ( x ) ;
88} ;
99
10- exports . unsafeToFixed = function ( n ) {
11- return function ( digits ) {
10+ exports . unsafeToFixed = function ( digits ) {
11+ return function ( n ) {
1212 return n . toFixed ( digits ) ;
1313 } ;
1414} ;
1515
16- exports . unsafeToExponential = function ( n ) {
17- return function ( digits ) {
16+ exports . unsafeToExponential = function ( digits ) {
17+ return function ( n ) {
1818 return n . toExponential ( digits ) ;
1919 } ;
2020} ;
2121
22- exports . unsafeToPrecision = function ( n ) {
23- return function ( digits ) {
22+ exports . unsafeToPrecision = function ( digits ) {
23+ return function ( n ) {
2424 return n . toPrecision ( digits ) ;
2525 } ;
2626} ;
Original file line number Diff line number Diff line change @@ -7,16 +7,16 @@ foreign import unsafeStringify :: forall a. a -> String
77-- | Formats Number as a String with limited number of digits after the dot
88-- | May throw RangeError if the number of digits is not within the allowed range
99-- | (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
1111
1212-- | Formats Number as String in exponential notation limiting number of digits
1313-- | after the decimal dot.
1414-- | May throw RangeError if the number of digits is not within the allowed range
1515-- | (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
1717
1818-- | Formats Number as String in fixed-point or exponential notation rounded
1919-- | to specified number of significant digits.
2020-- | May throw RangeError if the number of digits is not within the allowed range
2121-- | (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
4545 assert $ readFloat " 3.5" == 3.5
4646
4747 -- 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"
5050
5151 -- 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"
5454
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"
5757
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"
6060
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"
6363
You can’t perform that action at this time.
0 commit comments