Arbitrary Arithmetic Library Written in Crystal

Hey all, purely for funsies and learning, I started an arbitrary arithmetic library written in crystal following the interface that crystal’s own big provides (I actually copied the big_int specs as a starting point). Over time I’d want to explore how big floats, rationals, and decimals also work under the hood, and improve the library overall. Contributions welcome if anyone wants to join in this journey of math discovery :slight_smile:

You can find it here!

4 Likes

Hello!

This link doesn’t work (404). Perhaps the repository is private?

1 Like

Well, that’s embarrassing, thank you for pointing that out :sweat_smile: a classic case of “it worked on my machine”

1 Like

Is it more memory efficient?

Still no.

This contradicts your benchmarks. It is significantly more memory efficient. Or am I missing something?

In any case, nice job! I hope it gets competitive in speed too.

1 Like

Doh! I see where I miscommunicated - the first two columns of the benchmark table are operations done in a 5-second period (a la Benchmark.ips; the benchmark table is really just a different format of its output). It’s not megabytes consumed by operation.

I did previously have a memory part of the benchmark, but I kept getting inconsistent results. Some operations it would report 0 bytes consumed (even though I knew there was memory being allocated), and in other cases it showed orders of magnitude more memory being consumed than I thought correct. I removed it since I was still implementing for correctness first. I should re-add that.

I’ll also remove those two columns for Operations, since it doesn’t really provide any value than the Avg Op Time columns already do. Great feedback!

1 Like

Updated benchmark script and README to show truly how atrocious the memory comparison is between bigger and big :grin:

1 Like

Not surprisingly at all, there’s almost a strict correlation between mem and speed :smiley:

1 Like

Looks like a fun project where you can learn a lot :rocket:

2 Likes