fixedpoint

Scaled Integer Arithmetic (4 Decimal Places)

Functions

FunctionDescription
_fp_byte_atInternal byte reader.
fp_from_intConvert integer to fixed-point.
fp_from_partsCreate from whole and fractional parts (frac is 0-9999).
fp_addAdd two fixed-point values.
fp_subSubtract two fixed-point values.
fp_mulMultiply two fixed-point values.
fp_divDivide two fixed-point values.
fp_wholeGet whole part.
fp_fracGet fractional part (0-9999).
fp_cmpCompare: -1, 0, or 1.
fp_absAbsolute value.
fp_sqrtSquare root of fixed-point value.
fp_to_strFormat fixed-point value to string. Returns length.
fp_from_strParse fixed-point from string. Returns scaled value.

Details

_fp_byte_at

fn _fp_byte_at(buf: &i8, idx: i64) -> i64

Internal byte reader.

fp_from_int

fn fp_from_int(n: i64) -> i64

Convert integer to fixed-point.

fp_from_parts

fn fp_from_parts(whole: i64, frac: i64) -> i64

Create from whole and fractional parts (frac is 0-9999).

fp_add

fn fp_add(a: i64, b: i64) -> i64

Add two fixed-point values.

fp_sub

fn fp_sub(a: i64, b: i64) -> i64

Subtract two fixed-point values.

fp_mul

fn fp_mul(a: i64, b: i64) -> i64

Multiply two fixed-point values.

fp_div

fn fp_div(a: i64, b: i64) -> i64

Divide two fixed-point values.

fp_whole

fn fp_whole(a: i64) -> i64

Get whole part.

fp_frac

fn fp_frac(a: i64) -> i64

Get fractional part (0-9999).

fp_cmp

fn fp_cmp(a: i64, b: i64) -> i64

Compare: -1, 0, or 1.

fp_abs

fn fp_abs(a: i64) -> i64

Absolute value.

fp_sqrt

fn fp_sqrt(a: i64) -> i64

Square root of fixed-point value.

fp_to_str

fn fp_to_str(a: i64, out: &i8) -> i64

Format fixed-point value to string. Returns length.

fp_from_str

fn fp_from_str(s: &i8, slen: i64) -> i64

Parse fixed-point from string. Returns scaled value.