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

misc decimal #690

Open
timotheecour opened this issue Apr 12, 2021 · 2 comments
Open

misc decimal #690

timotheecour opened this issue Apr 12, 2021 · 2 comments

Comments

@timotheecour
Copy link
Owner

timotheecour commented Apr 12, 2021

performance

for nim-lang#17699, we should have a performance comparison against established decimal128 libraries.

links

Starting from Python-3.3, libmpdec is the basis for Python’s decimal module.

  • python3: import decimal
@JohnAD
Copy link

JohnAD commented Apr 12, 2021

A more direct comparison would be with:

http://mongoc.org/libbson/current/index.html

The 'bson' implementation of decimal is the same fixed "bid" 128-bit IEEE 754-2008 standard.

The python version (which is mpdecimal) is a dynamic 32/64/128-bit of a variant of the same standard.

I'm confident both mpdecimal and mongoc are faster at the moment since I've not done any optimization.

(I have freely studied the algorithms from both to help write my library.)

@JohnAD
Copy link

JohnAD commented Apr 12, 2021

Speaking of that; is there any movement to adding 128-bit integers to Nim?

GCC 4.1 and later support __int128_t and __uint128_t along with the relevant ops; at least on 64-bit platforms.

Using 128-bit uint math on the significand (the numbers part) for some of the ops would very likely improve speed quite a bit.

(EDIT)

https://github.com/python/cpython/blob/63298930fb531ba2bb4f23bc3b915dbf1e17e9e1/Modules/_decimal/README.txt

Yeah, I kind of recall this now. If 128 bit support in a 64 bit architecture is detected, mpdecimal totally uses uint128 for the math.

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

2 participants