Float32
Edit on GitHubUtilities for working with the Float32 type.
Added in 0.2.0
No other changes yet.
Values
Functions and constants included in the Float32 module.
Float32.infinity
Added in 0.4.0
No other changes yet.
Infinity represented as a Float32 value.
This is an alternative to the Infinityf
literal.
Float32.nan
Added in 0.4.0
No other changes yet.
NaN (Not a Number) represented as a Float32 value.
This is an alternative to the NaNf
literal.
Float32.pi
Added in 0.5.2
No other changes yet.
Pi represented as a Float32 value.
Float32.tau
Added in 0.5.2
No other changes yet.
Tau represented as a Float32 value.
Float32.e
Added in 0.5.2
No other changes yet.
Euler’s number represented as a Float32 value.
Float32.fromNumber
Added in 0.2.0
No other changes yet.
Converts a Number to a Float32.
Parameters:
param | type | description |
---|---|---|
number |
Number |
The value to convert |
Returns:
type | description |
---|---|
Float32 |
The Number represented as a Float32 |
Float32.toNumber
Added in 0.2.0
No other changes yet.
Converts a Float32 to a Number.
Parameters:
param | type | description |
---|---|---|
float |
Float32 |
The value to convert |
Returns:
type | description |
---|---|
Number |
The Float32 represented as a Number |
Float32.reinterpretInt32
Added in 0.7.0
No other changes yet.
Interprets an Int32 as a Float32.
Parameters:
param | type | description |
---|---|---|
value |
Int32 |
The value to convert |
Returns:
type | description |
---|---|
Float32 |
The Int32 interpreted as an Float32 |
Examples:
Float32.reinterpretUint32
Added in 0.7.0
No other changes yet.
Interprets an Uint32 as a Float32.
Parameters:
param | type | description |
---|---|---|
value |
Uint32 |
The value to convert |
Returns:
type | description |
---|---|
Float32 |
The Uint32 interpreted as an Float32 |
Examples:
Float32.(+)
Added in 0.6.0
version | changes |
---|---|
0.2.0 | Originally named `add` |
Computes the sum of its operands.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The first operand |
y |
Float32 |
The second operand |
Returns:
type | description |
---|---|
Float32 |
The sum of the two operands |
Examples:
Float32.(-)
Added in 0.6.0
version | changes |
---|---|
0.2.0 | Originally named `sub` |
Computes the difference of its operands.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The first operand |
y |
Float32 |
The second operand |
Returns:
type | description |
---|---|
Float32 |
The difference of the two operands |
Examples:
Float32.(*)
Added in 0.6.0
version | changes |
---|---|
0.2.0 | Originally named `mul` |
Computes the product of its operands.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The first operand |
y |
Float32 |
The second operand |
Returns:
type | description |
---|---|
Float32 |
The product of the two operands |
Examples:
Float32.(/)
Added in 0.6.0
version | changes |
---|---|
0.2.0 | Originally named `div` |
Computes the quotient of its operands.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The first operand |
y |
Float32 |
The second operand |
Returns:
type | description |
---|---|
Float32 |
The quotient of the two operands |
Examples:
Float32.(**)
Added in 0.7.0
No other changes yet.
Computes the exponentiation of the given base and power.
Parameters:
param | type | description |
---|---|---|
base |
Float32 |
The base float |
power |
Float32 |
The exponent float |
Returns:
type | description |
---|---|
Float32 |
The base raised to the given power |
Examples:
Float32.(<)
Added in 0.6.0
version | changes |
---|---|
0.2.0 | Originally named `lt` |
Checks if the first value is less than the second value.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The first value |
y |
Float32 |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is less than the second value or false otherwise |
Examples:
Float32.(>)
Added in 0.6.0
version | changes |
---|---|
0.2.0 | Originally named `gt` |
Checks if the first value is greater than the second value.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The first value |
y |
Float32 |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is greater than the second value or false otherwise |
Examples:
Float32.(<=)
Added in 0.6.0
version | changes |
---|---|
0.2.0 | Originally named `lte` |
Checks if the first value is less than or equal to the second value.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The first value |
y |
Float32 |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is less than or equal to the second value or false otherwise |
Examples:
Float32.(>=)
Added in 0.6.0
version | changes |
---|---|
0.2.0 | Originally named `gte` |
Checks if the first value is greater than or equal to the second value.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The first value |
y |
Float32 |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is greater than or equal to the second value or false otherwise |
Examples:
Float32.isFinite
Added in 0.7.0
No other changes yet.
Checks if a float is finite. All values are finite exept for NaN, infinity or negative infinity.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The number to check |
Returns:
type | description |
---|---|
Bool |
true if the value is finite or false otherwise |
Examples:
Float32.isNaN
Added in 0.6.5
No other changes yet.
Checks if the value is a float NaN value (Not A Number).
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The value to check |
Returns:
type | description |
---|---|
Bool |
true if the value is NaN, otherwise false |
Examples:
Float32.isInfinite
Added in 0.6.5
No other changes yet.
Checks if a float is infinite, that is either of positive or negative infinity.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The value to check |
Returns:
type | description |
---|---|
Bool |
true if the value is infinite or false otherwise |
Examples:
Float32.min
Added in 0.7.0
No other changes yet.
Returns the smaller of its operands.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The first operand |
y |
Float32 |
The second operand |
Returns:
type | description |
---|---|
Float32 |
The smaller of the two operands |
Examples:
Float32.max
Added in 0.7.0
No other changes yet.
Returns the larger of its operands.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The first operand |
y |
Float32 |
The second operand |
Returns:
type | description |
---|---|
Float32 |
The larger of the two operands |
Examples:
Float32.abs
Added in 0.6.5
No other changes yet.
Returns the absolute value. That is, it returns x
if x
is positive or zero and the negation of x
if x
is negative.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The operand |
Returns:
type | description |
---|---|
Float32 |
The absolute value of the operand |
Examples:
Float32.neg
Added in 0.6.5
No other changes yet.
Returns the negation of its operand.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The operand |
Returns:
type | description |
---|---|
Float32 |
The negated operand |
Examples:
Float32.ceil
Added in 0.7.0
No other changes yet.
Rounds its operand up to the next largest whole value.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The operand to ceil |
Returns:
type | description |
---|---|
Float32 |
The next largest whole value of the operand |
Examples:
Float32.floor
Added in 0.7.0
No other changes yet.
Rounds its operand down to the largest whole value less than the operand.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The operand to floor |
Returns:
type | description |
---|---|
Float32 |
The previous whole value of the operand |
Examples:
Float32.trunc
Added in 0.7.0
No other changes yet.
Returns the whole value part of its operand, removing any fractional value.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The operand to truncate |
Returns:
type | description |
---|---|
Float32 |
The whole value part of the operand |
Examples:
Float32.round
Added in 0.7.0
No other changes yet.
Returns its operand rounded to its nearest integer.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The operand to round |
Returns:
type | description |
---|---|
Float32 |
The nearest integer to the operand |
Examples:
Float32.sqrt
Added in 0.7.0
No other changes yet.
Computes the square root of its operand.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The operand to square root |
Returns:
type | description |
---|---|
Float32 |
The square root of the operand |
Examples:
Float32.copySign
Added in 0.7.0
No other changes yet.
Copys the sign of the second operand to the first operand.
Parameters:
param | type | description |
---|---|---|
x |
Float32 |
The operand to modify |
y |
Float32 |
The operand to copy the sign from |
Returns:
type | description |
---|---|
Float32 |
The first operand with the sign of the second operand |
Examples:
Float32.isClose
Added in 0.7.0
No other changes yet.
1 | isClose: |
Determines whether two values are considered close to each other using a relative and absolute tolerance.
Parameters:
param | type | description |
---|---|---|
a |
Float32 |
The first value |
b |
Float32 |
The second value |
?relativeTolerance |
Float32 |
The maximum tolerance to use relative to the larger absolute value a or b |
?absoluteTolerance |
Float32 |
The absolute tolerance to use, regardless of the values of a or b |
Returns:
type | description |
---|---|
Bool |
true if the values are considered close to each other or false otherwise |
Examples:
Float32.sin
Added in 0.7.0
No other changes yet.
Computes the sine of a float (in radians).
Parameters:
param | type | description |
---|---|---|
radians |
Float32 |
The input in radians |
Returns:
type | description |
---|---|
Float32 |
The computed sine |
Examples:
Float32.cos
Added in 0.7.0
No other changes yet.
Computes the cosine of a float (in radians).
Parameters:
param | type | description |
---|---|---|
radians |
Float32 |
The input in radians |
Returns:
type | description |
---|---|
Float32 |
The computed cosine |
Examples:
Float32.tan
Added in 0.7.0
No other changes yet.
Computes the tangent of a number (in radians).
Parameters:
param | type | description |
---|---|---|
radians |
Float32 |
The input in radians |
Returns:
type | description |
---|---|
Float32 |
The computed tangent |
Examples: