prev-float ( m -- n ) (original) (raw)

prev-float ( m -- n )
Factor handbook » The language » Numbers » Floats » Bitwise operations on floats

Prev: ( payload -- nan )
Next: next-float ( m -- n )

Vocabulary
math

Inputs

m a float

Outputs

n a float

Word description
Returns the greatest representable float value less than m, or in the case of +0.0, returns -0.0.

See also
next-float

Definition

IN: math

GENERIC: prev-float ( m -- n )

Methods

USING: kernel math ;

M: float prev-float
double>bits dup -0.0 double>bits >=
[ 1 + bits>double ] [
dup 0.0 double>bits =
[ drop -0.0 ] [ 1 - bits>double ] if
] if ; inline