fuzzyfields/numbers.py
def _num_converter(self, value: Any) -> decimal.Decimal:
        """Convert string, float, or int to decimal.Decimal
        """
        # Performance shortcut
        if isinstance(value, decimal.Decimal):
            return value

        orig_value = value
        # Remove leading zeros after comma, as they confuse Decimal
        # e.g.  Decimal('0.0000000000') -> Decimal("0E-10")
        # Do not accidentally drop leading zeros in the exponent.
        if isinstance(value, str):
            value = value.upper()
            if 'E' in value:
                # Scientific notation
                mantissa, _, exponent = value.partition('E')
                if '.' in mantissa:
                    mantissa = re.sub(r'0*$', '', mantissa)
                value = f'{mantissa}E{exponent}'
            elif '.' in value:
                # Not scientific notation
                value = re.sub(r'0*$', '', value)

        try:
            return decimal.Decimal(value)
        except (TypeError, ValueError):
            raise FieldTypeError(self.name, orig_value, "number")
        except decimal.InvalidOperation:
            raise MalformedFieldError(self.name, orig_value, "number")
Convert string, float, or int to decimal.Decimal
        
Convert string, float, or int to decimal.Decimal
Convert string float or int to decimal . Decimal
def _num_converter(self, value: Any) -> decimal.Decimal:
        if isinstance(value, decimal.Decimal):
            return value
        orig_value = value
        if isinstance(value, str):
            value = value.upper()
            if 'E' in value:
                mantissa, _, exponent = value.partition('E')
                if '.' in mantissa:
                    mantissa = re.sub(r'0*$', '', mantissa)
                value = f'{mantissa}E{exponent}'
            elif '.' in value:
                value = re.sub(r'0*$', '', value)
        try:
            return decimal.Decimal(value)
        except (TypeError, ValueError):
            raise FieldTypeError(self.name, orig_value, "number")
        except decimal.InvalidOperation:
            raise MalformedFieldError(self.name, orig_value, "number")
def _num_converter ( self , value : Any ) -> decimal . Decimal : if isinstance ( value , decimal . Decimal ) : return value orig_value = value if isinstance ( value , str ) : value = value . upper ( ) if 'E' in value : mantissa , _ , exponent = value . partition ( 'E' ) if '.' in mantissa : mantissa = re . sub ( r'0*$' , '' , mantissa ) value = f'{mantissa}E{exponent}' elif '.' in value : value = re . sub ( r'0*$' , '' , value ) try : return decimal . Decimal ( value ) except ( TypeError , ValueError ) : raise FieldTypeError ( self . name , orig_value , "number" ) except decimal . InvalidOperation : raise MalformedFieldError ( self . name , orig_value , "number" )
Convert string, float, or int to decimal.Decimal
Convert string float or int to decimal . Decimal
"""Convert string, float, or int to decimal.Decimal
        """ # Performance shortcut # Remove leading zeros after comma, as they confuse Decimal # e.g.  Decimal('0.0000000000') -> Decimal("0E-10") # Do not accidentally drop leading zeros in the exponent. # Scientific notation # Not scientific notation
self
value
Any