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. 1.10
  2. 1.110
  3. 2.0
  4. 2.1340

expected result:

  1. "110"
  2. "1110"
  3. "20"
  4. "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

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -