Skip to content

DecimalConverter.MaxPrecision can overflow for large type widths #645

@adamreeve

Description

@adamreeve

For decimal type lengths > 128 bytes, the power term becomes infinity. This is probably unlikely in practice, but the following expression for the max precision is equivalent and avoids this overflow:

(int) Math.Floor((8.0 * length - 1) * Math.Log10(2))

This is what's used in Parquet C++, see apache/arrow@423ca16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions