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
this disclaimer
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
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

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