10i64.pow(u32::try_from(exp.abs()) overflowed for large numbers. The public BigDecimal API splits the computation and performs the power on a BigInt to avoid this overflow.
Let me know if you think it's better to own this code. There's no public issue because this was discovered while working on JSON protocol which lifted some GQL int boundary limitation and made it possible to cross this code path. Specifically, it made this test fail.
Overview
Discovered while working on https://github.com/prisma/client-planning/issues/237
10i64.pow(u32::try_from(exp.abs())
overflowed for large numbers. The public BigDecimal API splits the computation and performs the power on aBigInt
to avoid this overflow.https://github.com/akubera/bigdecimal-rs/blob/master/src/lib.rs#L76-L94
Let me know if you think it's better to own this code. There's no public issue because this was discovered while working on JSON protocol which lifted some GQL int boundary limitation and made it possible to cross this code path. Specifically, it made this test fail.