Skip to content

128-bit Unsigned Overflow-safe Currency

Luke Champine requested to merge 128bit into master

I'm going to need some help with most of the overflow checks here. It isn't always clear how the error should be handled.

It occurred to me that it'd be most convenient to just embed a *big.Int in the Currency type. Then you wouldn't need pass-through functions. The problem, of course, is that that the pass-through functions are what catch the overflow errors. So now we're back to manual overflow checking. ...which I still think is a reasonable approach. I mean, there are tons of integers in the codebase that could potentially overflow, and they aren't being checked at all. Even manual checking is a lot better than nothing, and it greatly increases readability. I think it would make some of the logic easier to handle too.

Merge request reports