3 examples of 'python decimal precision' in Python

Every line of 'python decimal precision' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
29def decimalPrecision(x):
30 """
31 get number od decimal places for float x
32 """
33 if isinstance(x, float):
34 try:
35 return len(str(x).split('.')[1])
36 except:
37 return 0
38 else:
39 return 0
537def test_validate_precision_with_digittuple(self):
538 instance = fields.DecimalField(max_digits=7, decimal_places=2)
539
540 value = Decimal('12345.0')
541 self.assertEqual(instance.validate_precision(value), value)
369def get_decimal_quantum(precision):
370 """Return minimal quantum of a number, as defined by precision."""
371 assert isinstance(precision, (int, long, decimal.Decimal))
372 return decimal.Decimal(10) ** (-precision)

Related snippets