fixed
Fixed-Point Type for f128
This module provides the core Fixed type for 64.64 fixed-point arithmetic.
Representation
Values are stored as a magnitude and sign:
mag: Absolute value scaled by 2^64 (ONE)sign:truefor negative,falsefor positive
Creating Fixed Values
use cairo_fp::f128::types::fixed::FixedTrait;
// From unscaled integer
let a = FixedTrait::new_unscaled(10, false); // 10.0
// From raw magnitude (already scaled)
let b = FixedTrait::new(18446744073709551616, false); // 1.0
// From felt252
let c = FixedTrait::from_unscaled_felt(5); // 5.0
// Constants
let zero = FixedTrait::ZERO();
let one = FixedTrait::ONE();
Fully qualified path: cairo_fp::f128::types::fixed
Constants
| PRIME | The Starknet field prime. |
| ONE | One (1.0) as a felt252, equal to 2^64. |
| ONE_u128 | One (1.0) as a u128, equal to 2^64. |
| HALF | Half (0.5) as a felt252, equal to 2^63. |
| HALF_u128 | Half (0.5) as a u128, equal to 2^63. |
| MAX_u128 | Maximum u128 value (2^128 - 1). |
Structs
| Fixed | A signed 64.64 fixed-point number. Uses 64 bits for the integer part and 64 bits for the fractional part, providing approximately 19 decimal digits of precision…. |
Traits
| FixedTrait | Trait defining operations for fixed-point numbers. Provides constructors, mathematical operations, trigonometric functions, and hyperbolic functions for the… |