Skip to content

max_decimal_places in Decimal field are wrong calculated #2947

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy