Skip to main content

to_fixed

Function to_fixed 

Source
pub fn to_fixed(x: f32) -> Fixed
Expand description

Converts a float value to Q15 fixed-point format.

§Input

  • x: A floating-point value in the range [-1.0, 1.0]

§Output

A Fixed value representing the input in Q15 format.

§Example

use fixed_math_taylor::to_fixed;

let f = to_fixed(0.5);
assert_eq!(f, 16384); // 0.5 * 32767 ≈ 16384