Arbitrary-precision fixed-point decimal numbers in go. Note: Decimal library can "only" represent numbers with a maximum of 2^31 digits after the decimal point. The zero-value is 0, and is safe to use without initialization. Addition, subtraction, and multiplication with no loss of precision. Division with specified precision. Database/sql serialization/deserialization. JSON and XML serialization/deserialization. big.Int's API is built to reduce the number of memory allocations for maximal performance. This makes sense for its use-case, but the trade-off is that the API is awkward and easy to misuse. In contrast, it's difficult to make such mistakes with decimal. Decimals behave like other go numbers types: even though a = b will not deep copy b into a, it is impossible to modify a Decimal, since all Decimal methods return new Decimals and do not modify the originals. The downside is that this causes extra allocations, so Decimal is less performant.

Features

  • Decimal library requires Go version >=1.7
  • The zero-value is 0, and is safe to use without initialization
  • Addition, subtraction, multiplication with no loss of precision
  • Division with specified precision
  • Database/sql serialization/deserialization
  • JSON and XML serialization/deserialization

Project Samples

Project Activity

See All Activity >

License

Apache License V2.0

Follow decimal

decimal Web Site

Other Useful Business Software
Build on Google Cloud with $300 in Free Credit Icon
Build on Google Cloud with $300 in Free Credit

New to Google Cloud? Get $300 in free credit to explore Compute Engine, BigQuery, Cloud Run, Vertex AI, and 150+ other products.

Start your next project with $300 in free Google Cloud credit. Spin up VMs, run containers, query exabytes in BigQuery, or build AI apps with Vertex AI and Gemini. Once your credits are used, keep building with 20+ products with free monthly usage, including Compute Engine, Cloud Storage, GKE, and Cloud Run functions. Sign up to start building right away.
Start Free Trial
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of decimal!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Programming Language

Go

Related Categories

Go Frameworks, Go JSON Serialization Libraries, Go XML Serialization Libraries

Registered

2023-01-10