Decimal points in python -
i have floating point values, these values dynamically generated:
float_a = 12.200 float_b = 14.0 float_c = 14.01880
i want remove decimal point them.
expected result
"12200" "140" "1401880"
i must careful these not fixed-point values , don't have control on how many decimal places input go to. more examples comments:
- 1.10
- 1.110
- 2.0
- 2.1340
expected result:
- "110"
- "1110"
- "20"
- "21340"
this question seems permutation of question has been answered:
the concept of leading zeros display concept, not numerical one. can put infinite number of leading zeros on number without changing value. since it's not numeric concept, it's not stored number.
you have decide how many zeros want when convert number string. keep number separately if want.
source: python force python keep leading zeros of int variables
it looks way asking if initial "float" in string form, otherwise trailing 0's dropped. if manage "float" string (before ever becoming float), can use int('12.200'.replace('.', ''))
method mentioned above
Comments
Post a Comment