Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python from float to decimal

# Python v2.7-
"%.15g" % f

# Python v3.0
format(f, ".15g")

# Python 2.7+, 3.2+
# Pass float to Decimal constructor
from decimal import Decimal
Decimal(f)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #float #decimal
ADD COMMENT
Topic
Name
4+6 =