prevfloat

prevfloat(f) -> AbstractFloat

Get the previous floating point number in lexicographic order

Examples

julia> prevfloat(3.5)
3.4999999999999996

julia> prevfloat(2.0)
1.9999999999999998

julia> prevfloat(1.0)
0.9999999999999999

The prevfloat function returns the previous floating-point number in lexicographic order. It is used to get the value that comes immediately before a given floating-point number.

Common mistake example:

julia> prevfloat(0.0)
-5.0e-324

In this example, the function returns -5.0e-324 which is the smallest representable positive subnormal floating-point number. This is because the previous floating-point number to 0.0 is a subnormal number, not a negative number. Make sure to understand the behavior of prevfloat when dealing with edge cases.

See Also

cmp, float, get_bigfloat_precision, get_rounding, get_zero_subnormals, isapprox, maxintfloat, mod2pi, nextfloat, precision, prevfloat, rationalize, round, set_bigfloat_precision, set_rounding, set_zero_subnormals, significand, with_bigfloat_precision, with_rounding,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: