Fixed point 64.61 math library for Cairo / Starknet
npm install @influenceth/cairo-math-64x61
A fixed point 64.61 math library for Cairo & Starknet
starknet-hardhat-plugin, install via npm with npm install --save-dev @influenceth/cairo-math-64x61 and add ./node_modules/@influenceth/cairo-math-64x61 to cairoPaths in your hardhat config (see https://github.com/Shard-Labs/starknet-hardhat-plugin#paths). Then you can import with, for example: from contracts.Math64x61 import Math64x61_mul64.61 is utilized as the 125 bit representation allows for overflow up to 2^125 * 2^125 (250 bits) during calculation taking advantage of Cairo's 251 bit felts.
Can represent values in the range of -2^64 to 2^64 with precision to 4.34e-19.
Math64x61 includes implementation of add, sub, mul, div, sqrt, exp, ln, log2, log10, and pow as well as conversion to / from felts and Uint256 values, floor, ceil, min, max and assertion methods.Trig64x61 includes implementation of sin, cos, tan and their inverses.Hyp64x61 includes implementation of sinh, cosh, tanh, and their inverses.Vec64x61 includes implementation of vector arithmetic (add, sub, div), dot product (dot), cross product (cross) and norm.