core :: Reader :: read_float
Float
Using this format may result in a loss of precision as it uses less bits
than Nit Float
.
Returns 0.0
when an error is pending (last_error != null
).
# Read a floating point on 32 bits and return it as a `Float`
#
# Using this format may result in a loss of precision as it uses less bits
# than Nit `Float`.
#
# Returns `0.0` when an error is pending (`last_error != null`).
fun read_float: Float
do
if last_error != null then return 0.0
var b0 = read_byte
var b1 = read_byte
var b2 = read_byte
var b3 = read_byte
# Check for error, `last_error` is set by `read_byte`
if b0 < 0 or b1 < 0 or b2 < 0 or b3 < 0 then return 0.0
return native_read_float(b0, b1, b2, b3, big_endian)
end
lib/binary/binary.nit:203,2--222,4