Skip to content

max_decimal_places in Decimal field are wrong calculated #2947

Closed
@bimusiek

Description

@bimusiek

We got an issue when number is formatted as decimal.Decimal('2E+9').

How DecimalField counts decimals:

    sign, digittuple, exponent = value.as_tuple()
    decimals = abs(exponent)

However result of decimal.Decimal('2E+9').as_tuple()[2] is 9, which is ok, but there are no decimal places in this number.

My solution is to not do abs and instead multiply by -1.

I can prepare PR tonight if you think it is valid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions