ESC
No recent searches
Search by
Standard Library  /  Float32

Float32

Utilities for working with the Float32 type.

Edit on GitHub
Added in 0.2.0 No other changes yet.
from "float32" include Float32
4.0f
-4.0f
Infinityf
NaNf

Values

Functions and constants included in the Float32 module.

Float32.infinity

Added in 0.4.0 No other changes yet.
infinity : Float32

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 : Float32

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 : Float32

Pi represented as a Float32 value.

Float32.tau

Added in 0.5.2 No other changes yet.
tau : Float32

Tau represented as a Float32 value.

Float32.e

Added in 0.5.2 No other changes yet.
e : Float32

Euler’s number represented as a Float32 value.

Float32.fromNumber

Added in 0.2.0 No other changes yet.
fromNumber : (number: Number) => Float32

Converts a Number to a Float32.

Parameters:

number: The value to convert

Returns:

Float32: The Number represented as a Float32

Float32.toNumber

Added in 0.2.0 No other changes yet.
toNumber : (float: Float32) => Number

Converts a Float32 to a Number.

Parameters:

float: The value to convert

Returns:

Number: The Float32 represented as a Number

Float32.(+)

Added in 0.6.0
versionchanges
0.2.0Originally named `add`
(+) : (x: Float32, y: Float32) => Float32

Computes the sum of its operands.

Parameters:

x: The first operand
y: The second operand

Returns:

Float32: The sum of the two operands

Examples:

use Float32.{ (+) }
assert 1.0f + 1.0f == 2.0f

Float32.(-)

Added in 0.6.0
versionchanges
0.2.0Originally named `sub`
(-) : (x: Float32, y: Float32) => Float32

Computes the difference of its operands.

Parameters:

x: The first operand
y: The second operand

Returns:

Float32: The difference of the two operands

Examples:

use Float32.{ (-) }
assert 1.0f - 1.0f == 0.0f

Float32.(*)

Added in 0.6.0
versionchanges
0.2.0Originally named `mul`
(*) : (x: Float32, y: Float32) => Float32

Computes the product of its operands.

Parameters:

x: The first operand
y: The second operand

Returns:

Float32: The product of the two operands

Examples:

use Float32.{ (*) }
assert 2.0f * 2.0f == 4.0f

Float32.(/)

Added in 0.6.0
versionchanges
0.2.0Originally named `div`
(/) : (x: Float32, y: Float32) => Float32

Computes the quotient of its operands.

Parameters:

x: The first operand
y: The second operand

Returns:

Float32: The quotient of the two operands

Examples:

use Float32.{ (/) }
assert 10.0f / 4.0f == 2.5f

Float32.(<)

Added in 0.6.0
versionchanges
0.2.0Originally named `lt`
(<) : (x: Float32, y: Float32) => Bool

Checks if the first value is less than the second value.

Parameters:

x: The first value
y: The second value

Returns:

Bool: true if the first value is less than the second value or false otherwise

Examples:

use Float32.{ (<) }
assert 1.0f < 2.0f

Float32.(>)

Added in 0.6.0
versionchanges
0.2.0Originally named `gt`
(>) : (x: Float32, y: Float32) => Bool

Checks if the first value is greater than the second value.

Parameters:

x: The first value
y: The second value

Returns:

Bool: true if the first value is greater than the second value or false otherwise

Examples:

use Float32.{ (>) }
assert 2.0f > 1.0f

Float32.(<=)

Added in 0.6.0
versionchanges
0.2.0Originally named `lte`
(<=) : (x: Float32, y: Float32) => Bool

Checks if the first value is less than or equal to the second value.

Parameters:

x: The first value
y: The second value

Returns:

Bool: true if the first value is less than or equal to the second value or false otherwise

Examples:

use Float32.{ (<=) }
assert -1.0f <= 1.0f
use Float32.{ (<=) }
assert -2.0f <= -2.0f

Float32.(>=)

Added in 0.6.0
versionchanges
0.2.0Originally named `gte`
(>=) : (x: Float32, y: Float32) => Bool

Checks if the first value is greater than or equal to the second value.

Parameters:

x: The first value
y: The second value

Returns:

Bool: true if the first value is greater than or equal to the second value or false otherwise

Examples:

use Float32.{ (>=) }
assert 4.0f >= 1.0f
use Float32.{ (>=) }
assert 3.0f >= 3.0f

Float32.isNaN

Added in 0.6.5 No other changes yet.
isNaN : (x: Float32) => Bool

Checks if the value is a float NaN value (Not A Number).

Parameters:

x: The value to check

Returns:

Bool: true if the value is NaN, otherwise false

Examples:

Float32.isNaN(NaNf)
Float32.isNaN(Infinityf) == false
Float32.isNaN(-Infinityf) == false
Float32.isNaN(0.5f) == false
Float32.isNaN(1.0f) == false

Float32.isInfinite

Added in 0.6.5 No other changes yet.
isInfinite : (x: Float32) => Bool

Checks if a float is infinite, that is either of positive or negative infinity.

Parameters:

x: The value to check

Returns:

Bool: true if the value is infinite or false otherwise

Examples:

Float32.isInfinite(Infinityf)
Float32.isInfinite(-Infinityf)
Float32.isInfinite(NaNf) == false
Float32.isInfinite(0.5f) == false
Float32.isInfinite(1.0f) == false

Float32.abs

Added in 0.6.5 No other changes yet.
abs : (x: Float32) => Float32

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:

x: The operand

Returns:

Float32: The absolute value of the operand

Examples:

Float32.abs(-1.0f) == 1.0f
Float32.abs(5.0f) == 5.0f

Float32.neg

Added in 0.6.5 No other changes yet.
neg : (x: Float32) => Float32

Returns the negation of its operand.

Parameters:

x: The operand

Returns:

Float32: The negated operand

Examples:

Float32.neg(-1.0f) == 1.0f
Float32.neg(1.0f) == -1.0f

Sign up for farm-to-inbox developer news

You can unsubscribe at any time. Read our privacy policy.

Copyright © 2024 The Grain Programming Language