Switch isFinite to isInfinite and improve documentation

This commit is contained in:
Evan Czaplicki 2014-03-20 18:26:43 -07:00
parent 804d895362
commit ef19d7146d
2 changed files with 24 additions and 10 deletions

View file

@ -30,9 +30,6 @@ are your tuples so big?
# Number Conversions
@docs round, floor, ceiling, truncate, toFloat
# Floating Point Checks
@docs isNaN, isFinite
# Angle Conversions
All angle conversions result in “standard Elm angles”
which happen to be radians.
@ -42,6 +39,9 @@ which happen to be radians.
# Polar Coordinates
@docs toPolar, fromPolar
# Floating Point Checks
@docs isNaN, isInfinite
# Tuples
@docs fst, snd
@ -274,17 +274,30 @@ ceiling = Native.Basics.ceiling
toFloat : Int -> Float
toFloat = Native.Basics.toFloat
{- | Determines whether a float is an undefined or unrepresentable number,
such as 0/0. NaN stands for *not a number*.
{- | Determines whether a float is an undefined or unrepresentable number.
NaN stands for *not a number* and it is [a standardized part of floating point
numbers](http://en.wikipedia.org/wiki/NaN).
isNaN (0/0) == True
isNaN (sqrt -1) == True
isNaN (1/0) == False -- infinity is a number
isNaN 1 == False
-}
isNaN : Float -> Bool
isNaN = Native.Basics.isNaN
{- | Determines whether a float is finite. Positive and negative infinity are
valid floating point numbers, created by computations like `1/0` and `-1/0`.
{- | Determines whether a float is positive or negative infinity.
isInfinite (0/0) == False
isInfinite (sqrt -1) == False
isInfinite (1/0) == True
isInfinite 1 == False
Notice that NaN is not infinite! For float `n` to be finite implies that
`not (isInfinite n || isNaN n)` evaluates to `True`.
-}
isFinite : Float -> Bool
isFinite = Native.Basics.isFinite
isInfinite : Float -> Bool
isInfinite = Native.Basics.isInfinite
-- Function Helpers

View file

@ -19,6 +19,7 @@ Elm.Native.Basics.make = function(elm) {
return Utils.cmp(n,lo) < 0 ? lo : Utils.cmp(n,hi) > 0 ? hi : n; }
function xor(a,b) { return a !== b; }
function not(b) { return !b; }
function isInfinite(n) { return n === Infinity || n === -Infinity }
function truncate(n) { return n|0; }
@ -54,7 +55,7 @@ Elm.Native.Basics.make = function(elm) {
round:Math.round,
toFloat:function(x) { return x; },
isNaN:isNaN,
isFinite:isFinite
isInfinite:isInfinite
};
return elm.Native.Basics.values = basics;