fixed-exp2

Crates.iofixed-exp2
lib.rsfixed-exp2
version0.2.0
created_at2025-01-11 22:12:07.260319+00
updated_at2025-01-11 22:12:07.260319+00
descriptionExponentiation for fixed-point numbers (forked, see README)
homepage
repositoryhttps://github.com/spookyvision/fixed-exp
max_upload_size
id1512780
size30,658
Anatol Ulrich (spookyvision)

documentation

README

fixed-exp

crates.io docs.rs

Exponentiation for fixed-point numbers. This is a manual fork of the original repository, which has vanished.

[dependencies]
fixed-exp = { git = "https://github.com/spookyvision/fixed-exp" }

Changes to the original

  • changed std::cmp imports to core::cmp to facilitate no_std compatibility
  • fixed broke semver by adding is_zero(). Removed from this crate.
  • removed crash by added special handling to powf where the integer part of the exponent is zero
  • rewrote powi (which is used by powf) to not use a greedy accumulator that would very quickly overflow (e.g. for 2**9 in I16F16). The new algorithm is slower, so the old behavior is preserved under the fast-powi feature flag.

Usage

This crate provides powi and powf for most fixed number types through the FixedPowI and FixedPowF extension traits:

use fixed::types::I32F32;
use fixed_exp::{FixedPowI, FixedPowF};

let x = I32F32::from_num(4.0);
assert_eq!(I32F32::from_num(1024.0), x.powi(5));
assert_eq!(I32F32::from_num(8.0), x.powf(I32F32::from_num(1.5)));

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 7

cargo fmt