How to do Decimal to float conversion in Python?
How to do Decimal to float conversion in Python?
There is two methods:
float_number = float ( decimal_number )
float_number = decimal_number * 1.0
First one using the built in function and second one without any function, but takecare about the 1.0
not 1
as it should be float so the result will be float.
Just use float
:
float_number = float(decimal_number)
How to do Decimal to float conversion in Python?
Just cast it to float:
number_in_float = float(number_you_have)