UpperBoundNonsortingDecimalSize returns the upper bound number of bytes that the decimal will need for the non-sorting encoding.
(d *apd.Decimal)
| 722 | // UpperBoundNonsortingDecimalSize returns the upper bound number of bytes |
| 723 | // that the decimal will need for the non-sorting encoding. |
| 724 | func UpperBoundNonsortingDecimalSize(d *apd.Decimal) int { |
| 725 | // Makeup of upper bound size: |
| 726 | // - 1 byte for the prefix |
| 727 | // - MaxVarintLen for the exponent |
| 728 | // - WordLen for the big.Int bytes |
| 729 | return 1 + MaxVarintLen + WordLen(d.Coeff.Bits()) |
| 730 | } |
| 731 | |
| 732 | // Taken from math/big/arith.go. |
| 733 | const bigWordSize = int(unsafe.Sizeof(big.Word(0))) |
no test coverage detected