Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

FixedTrait

Trait defining operations for fixed-point numbers.

Provides constructors, mathematical operations, trigonometric functions, and hyperbolic functions for the Fixed type.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait

trait FixedTrait

Trait functions

ZERO

Returns zero (0.0).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::ZERO

fn ZERO() -> Fixed

ONE

Returns one (1.0).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::ONE

fn ONE() -> Fixed

new

Creates a new fixed-point number from a pre-scaled magnitude.

Arguments

  • mag - The magnitude, already scaled by 2^64
  • sign - true for negative, false for positive

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::new

fn new(mag: u128, sign: bool) -> Fixed

new_unscaled

Creates a new fixed-point number from an unscaled integer.

The value is automatically scaled by ONE (2^64).

Arguments

  • mag - The integer value
  • sign - true for negative, false for positive

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::new_unscaled

fn new_unscaled(mag: u128, sign: bool) -> Fixed

from_felt

Creates a fixed-point number from a felt252 (pre-scaled).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::from_felt

fn from_felt(val: felt252) -> Fixed

from_unscaled_felt

Creates a fixed-point number from an unscaled felt252.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::from_unscaled_felt

fn from_unscaled_felt(val: felt252) -> Fixed

abs

Returns the absolute value.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::abs

fn abs(self: Fixed) -> Fixed

ceil

Rounds up to the nearest integer.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::ceil

fn ceil(self: Fixed) -> Fixed

exp

Calculates e^x (natural exponential).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::exp

fn exp(self: Fixed) -> Fixed

exp2

Calculates 2^x (binary exponential).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::exp2

fn exp2(self: Fixed) -> Fixed

floor

Rounds down to the nearest integer.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::floor

fn floor(self: Fixed) -> Fixed

ln

Calculates ln(x) (natural logarithm). Panics if x <= 0.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::ln

fn ln(self: Fixed) -> Fixed

log2

Calculates log2(x) (base-2 logarithm). Panics if x <= 0.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::log2

fn log2(self: Fixed) -> Fixed

log10

Calculates log10(x) (base-10 logarithm). Panics if x <= 0.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::log10

fn log10(self: Fixed) -> Fixed

pow

Calculates x^b (power function).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::pow

fn pow(self: Fixed, b: Fixed) -> Fixed

round

Rounds to the nearest integer (half up).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::round

fn round(self: Fixed) -> Fixed

sqrt

Calculates the square root. Panics if x < 0.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::sqrt

fn sqrt(self: Fixed) -> Fixed

acos

Calculates arccos(x). Domain: -1, 1.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::acos

fn acos(self: Fixed) -> Fixed

acos_fast

Fast arccos using lookup table.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::acos_fast

fn acos_fast(self: Fixed) -> Fixed

asin

Calculates arcsin(x). Domain: -1, 1.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::asin

fn asin(self: Fixed) -> Fixed

asin_fast

Fast arcsin using lookup table.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::asin_fast

fn asin_fast(self: Fixed) -> Fixed

atan

Calculates arctan(x).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::atan

fn atan(self: Fixed) -> Fixed

atan_fast

Fast arctan using lookup table.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::atan_fast

fn atan_fast(self: Fixed) -> Fixed

cos

Calculates cos(x) using Taylor series.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::cos

fn cos(self: Fixed) -> Fixed

cos_fast

Fast cos using lookup table.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::cos_fast

fn cos_fast(self: Fixed) -> Fixed

sin

Calculates sin(x) using Taylor series.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::sin

fn sin(self: Fixed) -> Fixed

sin_fast

Fast sin using lookup table.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::sin_fast

fn sin_fast(self: Fixed) -> Fixed

tan

Calculates tan(x). Panics at x = ΀/2 + n΀.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::tan

fn tan(self: Fixed) -> Fixed

tan_fast

Fast tan using lookup table.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::tan_fast

fn tan_fast(self: Fixed) -> Fixed

acosh

Calculates acosh(x). Domain: x >= 1.

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::acosh

fn acosh(self: Fixed) -> Fixed

asinh

Calculates asinh(x).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::asinh

fn asinh(self: Fixed) -> Fixed

atanh

Calculates atanh(x). Domain: (-1, 1).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::atanh

fn atanh(self: Fixed) -> Fixed

cosh

Calculates cosh(x).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::cosh

fn cosh(self: Fixed) -> Fixed

sinh

Calculates sinh(x).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::sinh

fn sinh(self: Fixed) -> Fixed

tanh

Calculates tanh(x).

Fully qualified path: cairo_fp::f128::types::fixed::FixedTrait::tanh

fn tanh(self: Fixed) -> Fixed