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

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

Prev: prev-float ( m -- n )
Next: fp-special? ( x -- ? )

Vocabulary
math

Inputs

m a float

Outputs

n a float

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

See also
prev-float

Definition

IN: math

GENERIC: next-float ( m -- n )

Methods

USING: kernel math ;

M: float next-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