Module
Data.Number
- Package
- purescript-numbers
- Repository
- purescript/purescript-numbers
Functions for working with PureScripts builtin Number type.
#fromString Source
fromString :: String -> Maybe NumberAttempt to parse a Number using JavaScripts parseFloat. Returns
Nothing if the parse fails or if the result is not a finite number.
Example:
> fromString "123"
(Just 123.0)
> fromString "12.34"
(Just 12.34)
> fromString "1e4"
(Just 10000.0)
> fromString "1.2e4"
(Just 12000.0)
> fromString "bad"
Nothing
Note that parseFloat allows for trailing non-digit characters and
whitespace as a prefix:
> fromString " 1.2 ??"
(Just 1.2)
#atan2 Source
atan2 :: Number -> Number -> NumberFour-quadrant tangent inverse. Given the arguments y and x, returns
the inverse tangent of y / x, where the signs of both arguments are used
to determine the sign of the result.
If the first argument is negative, the result will be negative.
The result is the angle between the positive x axis and a point (x, y).
> atan2 0.0 1.0
0.0
> atan2 1.0 0.0 == pi / 2.0
true