[−][src]Trait binjs_io::bytes::float::WriteVarFloat
Utility for manipulating of varfloats
, a somewhat optimized representation of floats.
This format is designed to help the most common floating point numbers (fairly short integers) take fewer bytes.
Instead of always fitting in 64 bits, varfloats are represented as follows:
- null is represented as VARNUM_NULL (24 bits);
- floats with an i32 value are transmuted to u32s and represented as signed varnums (8 to 40 bits, where numbers in [-63, 63] fit in 8 bits);
- other float values are prefixed with VARNUM_PREFIX_FLOAT (16 bits), then represented with the usual 64 bits.
Required methods
fn write_maybe_varfloat(&mut self, value: Option<f64>) -> Result<usize, Error>
fn write_varfloat(&mut self, num: f64) -> Result<usize, Error>
Provided methods
fn write_maybe_varfloat2(&mut self, value: Option<F64>) -> Result<usize, Error>
Utility: as write_maybe_varfloat
but with a F64
instead of a f64
.
fn write_varfloat2(&mut self, num: F64) -> Result<usize, Error>
Utility: as write_varfloat
but with a F64
instead of a f64
.