Skip to content

yamavol/decimal3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Decimal3

Decimal3 is a c++ class for 3 digits precision fixed-point decimals.

Major features:

  • Initialize from integer, double, string, and internal value.
  • Simple arithmetic operations: add, subtract, multiply, and divide
  • No exception
  • Easy error detection on conversion, creation, and overflow
  • Keep implementation simple for easy porting

Precision

Decimal value is stored as x1000 scaled 64bit integer. Thus, handling large values will easily lead to overflow. If an overflow is detected, the value is replaced with Decimal3::ErrorValue. You can check error with Decimal3::error() anytime.

The range supported will be between ±9e15 (9227 trillion). This is big enough to store Double's MaxSafeNum (9e15, 9007 trillion) but it is recommended to use for values under ±9e12 to not to round off decimal values.

License

Boost Software License

About

C++ class to store decimals with 3 digits precision in 64bit integer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published