timotheecour / Nim

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
http://nim-lang.org/
Other
2 stars 0 forks source link

misc decimal #690

Open timotheecour opened 3 years ago

timotheecour commented 3 years ago

performance

for https://github.com/nim-lang/Nim/pull/17699, we should have a performance comparison against established decimal128 libraries.

links

JohnAD commented 3 years ago

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 commented 3 years ago

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.