Skip to main content

Fixed point 64.61 math library for Cairo / Starknet

Project description

npm version

Cairo Math 64x61

A fixed point 64.61 math library for Cairo & Starknet

Usage

Install with pip install cairo_math_64x61 and import with ex. from cairo_math_64x61.math64x61 import Math64x61. Previous installation as an npm module has been deprecated, the last available npm module will be v1.2.0.

Signed 64.61 Fixed Point Numbers

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

64.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.

Standard Library

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.

Trigonometry Library

trig64x61 includes implementation of sin, cos, tan and their inverses.

Hyperbolic Library

hyp64x61 includes implementation of sinh, cosh, tanh, and their inverses.

Vector Library

vec64x61 includes implementation of vector arithmetic (add, sub, div), dot product (dot), cross product (cross) and norm.

Extensibility

This library strives to adhere to the OpenZeppelin extensibility pattern: https://docs.openzeppelin.com/contracts-cairo/0.2.1/extensibility#libraries

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cairo_math_64x61-1.3.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cairo_math_64x61-1.3.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file cairo_math_64x61-1.3.0.tar.gz.

File metadata

  • Download URL: cairo_math_64x61-1.3.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.12

File hashes

Hashes for cairo_math_64x61-1.3.0.tar.gz
Algorithm Hash digest
SHA256 7c4348865464e7b483d8f6f5da9fb01c973d4551bbc7e00294bf3c3fca6bcdbc
MD5 e398a0dbd7d6dbb5892f932cb2f5873f
BLAKE2b-256 d93764107371e1155a88289253ba659622c90e77e455031962f224cb614a2a5d

See more details on using hashes here.

File details

Details for the file cairo_math_64x61-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cairo_math_64x61-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3a96ac9549d03ac1196d8946036bee672e8bb095add9308625e84ed65f18414
MD5 435f211243270dbde4d6eae2b9ba3cf6
BLAKE2b-256 495494eae9d411f51513f4f90c6171bf6e86fababaf54582d99b09a2cd99efab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page