Skip to content

Fixed Point Arithmetic

fx32_32_t fx_add(fx32_32_t a, fx32_32_t b);

fx_add referenced types:

fx32_32_t fx_sub(fx32_32_t a, fx32_32_t b);

fx_sub referenced types:

fx32_32_t fx_mul(fx32_32_t a, fx32_32_t b);

fx_mul referenced types:

fx32_32_t fx_div(fx32_32_t a, fx32_32_t b);

fx_div referenced types:

fx32_32_t fx_from_int(int64_t x);

fx_from_int referenced types:

int64_t fx_to_int(fx32_32_t x);

fx_to_int referenced types:

fx32_32_t fx_from_float(double v);

fx_from_float referenced types:

fx32_32_t fx_min(fx32_32_t a, fx32_32_t b);

fx_min referenced types:

fx32_32_t fx_max(fx32_32_t a, fx32_32_t b);

fx_max referenced types:

fx32_32_t fx_clamp(fx32_32_t x, fx32_32_t lo, fx32_32_t hi);

fx_clamp referenced types:

fx32_32_t fx_pow_i32(fx32_32_t base, int exp);

fx_pow_i32 referenced types:

fx32_32_t fx_sqrt(fx32_32_t x);

fx_sqrt referenced types:

#define FX_ONE ((fx32_32_t) (1LL << 32))
#define FX_HALF ((fx32_32_t) (1LL << 31))
#define FX(x) ((fx32_32_t) ((x) * 4294967296.0 + 0.5))
#define FX_FROM_RATIO(n, d) ((fx32_32_t) (((__int128) (n) << 32) / (d)))