savi-lang / savi

A fast language for programmers who are passionate about their craft.
BSD 3-Clause "New" or "Revised" License
155 stars 12 forks source link

Add `U64.BCD` and use it to format decimal Integers #358

Closed mneumann closed 1 year ago

mneumann commented 1 year ago

Not sure if this is of any use. It emerged out of the idea of converting decimals via BCDs :)

I think what could be useful is a BitArrayPair(T), that takes two T (e.g. U64) and provides operations that operate on both (bit shifting, rotation etc.). Most of the complexity of the code below comes from simulating bit shifts via two U64.

jemc commented 1 year ago

You were probably already planning to include this here, but I'm in agreement with your comment on my other PR about using BCD for the implementation of Integer.Format.Decimal.

Arguably its use in Integer.Format.Decimal is the best argument for including a BCD implementation in the core library instead of as a separate standard library.

jemc commented 1 year ago

Looks like an internal error in the compiler being triggered here. I can take a look.

mneumann commented 1 year ago

@jemc okay if I merge this?