fixed
f64 Fixed-Point Type
A 32.32 fixed-point number implementation optimized for gas efficiency. Uses 64-bit storage with 32 bits for the integer part and 32 bits for the fractional part.
Format
- Total bits: 64 - Integer bits: 32 (range: ±2³¹) - Fractional bits: 32 (precision: ~2×10⁻¹⁰)
Gas Savings
Compared to f128 (64.64 format), f64 typically uses 40-60% less gas for equivalent operations due to smaller integer arithmetic.
Example
use cairo_fp::f64::types::fixed::FixedTrait;
let a = FixedTrait::new_unscaled(10, false); // 10.0
let b = FixedTrait::new(2147483648, false); // 0.5 (HALF)
let c = a * b; // 5.0
Fully qualified path: cairo_fp::f64::types::fixed
Constants
| TWO | Two in fixed-point representation (2 × 2³²). |
| ONE | One in fixed-point representation (2³²). This is the scaling factor for the 32.32 format. |
| HALF | Half in fixed-point representation (2³¹). |
| MAX_u64 | Maximum value for u64. |
Structs
| Fixed | A signed 32.32 fixed-point number. The magnitude is stored as a u64 where the upper 32 bits represent the integer part and the lower 32 bits represent the fractional part…. |
Traits
| FixedTrait | Core trait for f64 fixed-point operations. Provides constructors, mathematical operations, trigonometric functions, and hyperbolic functions for the Fixed type. |