fixedpoint
Scaled Integer Arithmetic (4 Decimal Places)
Functions
| Function | Description |
|---|---|
_fp_byte_at | Internal byte reader. |
fp_from_int | Convert integer to fixed-point. |
fp_from_parts | Create from whole and fractional parts (frac is 0-9999). |
fp_add | Add two fixed-point values. |
fp_sub | Subtract two fixed-point values. |
fp_mul | Multiply two fixed-point values. |
fp_div | Divide two fixed-point values. |
fp_whole | Get whole part. |
fp_frac | Get fractional part (0-9999). |
fp_cmp | Compare: -1, 0, or 1. |
fp_abs | Absolute value. |
fp_sqrt | Square root of fixed-point value. |
fp_to_str | Format fixed-point value to string. Returns length. |
fp_from_str | Parse fixed-point from string. Returns scaled value. |
Details
_fp_byte_at
fn _fp_byte_at(buf: &i8, idx: i64) -> i64Internal byte reader.
fp_from_int
fn fp_from_int(n: i64) -> i64Convert integer to fixed-point.
fp_from_parts
fn fp_from_parts(whole: i64, frac: i64) -> i64Create from whole and fractional parts (frac is 0-9999).
fp_add
fn fp_add(a: i64, b: i64) -> i64Add two fixed-point values.
fp_sub
fn fp_sub(a: i64, b: i64) -> i64Subtract two fixed-point values.
fp_mul
fn fp_mul(a: i64, b: i64) -> i64Multiply two fixed-point values.
fp_div
fn fp_div(a: i64, b: i64) -> i64Divide two fixed-point values.
fp_whole
fn fp_whole(a: i64) -> i64Get whole part.
fp_frac
fn fp_frac(a: i64) -> i64Get fractional part (0-9999).
fp_cmp
fn fp_cmp(a: i64, b: i64) -> i64Compare: -1, 0, or 1.
fp_abs
fn fp_abs(a: i64) -> i64Absolute value.
fp_sqrt
fn fp_sqrt(a: i64) -> i64Square root of fixed-point value.
fp_to_str
fn fp_to_str(a: i64, out: &i8) -> i64Format fixed-point value to string. Returns length.
fp_from_str
fn fp_from_str(s: &i8, slen: i64) -> i64Parse fixed-point from string. Returns scaled value.