Skip to content

tarrencev/cubit

 
 

Repository files navigation

Cubit

Workflow Tests Status License: MIT

A fixed point math library in 64.64 representation built for Cairo 1.0 & Starknet. Successor to influenceth/cairo-math-64x61

Cubit is currently a WORK IN PROGRESS and should not be used in production (yet). Contributions are welcomed.

Usage

Cubit was built with auditless/cairo-template, reference its installation guide to install dependencies.

Signed 64.64 Fixed Point Numbers

A signed 64.64-bit fixed point number is a fraction in which the numerator is a signed 128-bit integer and the denominator is 2^64. Since the denominator stays the same there is no need to store it (as in a floating point value).

Can represent values in the range of -2^64 to 2^64 with precision to 1e-20.

Core Library

cubit::core includes the following implementations for the Fixed type:

  • FixedTrait::from_felt - creates a Fixed type from a pre-scaled felt
  • FixedTrait::from_int - creates and scales a felt into a Fixed type
  • Into (fixed.into()) - converts the Fixed value into a felt
  • Add (+)
  • AddEq (+=)
  • Sub (-)
  • SubEq (-=)
  • Mul (*)
  • MulEq (*=)
  • Div (/)
  • DivEq (/=)
  • PartialEq (==, !=)
  • PartialOrd (>, >=, <, <=)
  • fixed.ceil
  • fixed.exp
  • fixed.floor
  • fixed.ln
  • fixed.log2
  • fixed.log10
  • fixed.pow
  • fixed.round
  • fixed.sqrt

License

MIT © Unstoppable Games, Inc.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 99.9%
  • Makefile 0.1%