Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal number representation for monetary amounts #144

Open
donmendelson opened this issue Feb 21, 2022 · 0 comments
Open

Decimal number representation for monetary amounts #144

donmendelson opened this issue Feb 21, 2022 · 0 comments

Comments

@donmendelson
Copy link
Member

Monetary amounts and prices are mostly exact decimal numbers. It is well documented that monetary amounts are poorly represented by binary single- and double-precision floating-point numbers that programmers are familiar with. This problem has a long and dreary history. C language and its descendants were originally developed for engineering problems such as telephone switches, not for financial applications. The languages that support decimal types often treat them as a class rather than as a primitive type. Due to poor and non-standard representations of decimal numbers in programming languages, we made a decision for SBE v1.0 to use a composite type of mantissa + exponent.

I would like to revisit that decision for SBE 2.x and am soliciting opinions on it. One of the drivers for reconsideration is digital tokens that may have exact decimals with high precision.

As a matter of fact, the IEEE-754:2008 standard does have representations of exact decimal floating-point numbers, along with the familiar binaries. It defines decimal32, decimal64, and decimal128 types. Recent versions of C and C++ have bindings to those types, but many other languages do not. Some may have accessibility through libraries.

Questions:

  • Are the IEEE-754:2008 decimal standards suitable for SBE?
  • Does even decimal128 support sufficient precision, or is arbitrary precision a requirement?
@donmendelson donmendelson added this to the SBE version 2.0 milestone Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant