gridcoin-community / Gridcoin-Research

Gridcoin-Research
MIT License
585 stars 173 forks source link

util: Enhance Fraction class overflow resistance #2735

Closed jamescowens closed 5 months ago

jamescowens commented 5 months ago

This makes fraction addition and multiplication more resistant to overflows. See the comments in the commits. This is about as far as we can go with this short of doing __int128_t internals, and that is not going to buy us much if the output has to fit within int64_t.