Struct rdir_encoding::IntegerEncoding [] [src]

pub struct IntegerEncoding;

Integer encoding.

In integer encoding, floating point numbers are converted to integer values by multiplying with a factor and discard everything after the decimal point. Depending on the multiplication factor this can change the precision but with a sufficiently large factor it is lossless. The integer values can then often be compressed with delta encoding which is the main motivation for it.

Examples

use rdir_encoding::IntegerEncoding;

let data = [1.00, 1.00, 0.50];
let encoded = IntegerEncoding::encode(&data, 100).unwrap();
assert_eq!(encoded, vec![100, 100, 50]);

let decoded = IntegerEncoding::decode(&encoded, 100).unwrap();
assert_eq!(decoded, data);

Methods

impl IntegerEncoding
[src]

[src]

Decode and return the decoded data

[src]

Encode any array of 'T' where T can be any Integer with an desired factor

Trait Implementations

impl Debug for IntegerEncoding
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations