Can we use a regular expression to convert a float to int using string? I have been trying a float multiplication and addition but I am stuck at floating point error.
My numbers are between 0.01 and 100.00
I first tried the direct float but it gives me float error https://codepen.io/anurag-desai/pen/QZKpbO
0.1+0.1+0.1 gives me an error of a rounding
So now I am trying another approach to convert all the numbers to integers and then add them so I could skip the entire float errors.
Problem: 0.29*100=28.9999996 instead of 29
So Can I use a regular expression for this?
Like it will remove the decimal places by considering the entire number as a string
ie:
0.01 ==>001
0.1==>010
1==>100
10 ==>1000
So I have this thought but no right way to do it
Step1: Standardise the float
0.01 ==>0.01
0.1==>0.10
1==>1.00
10 ==>10.00
Step 2: Remove the deicmal point.
Step3: Convert to Int and use this as Integer
But I am not able to get the regular expression for standardizing
Can someone help me with this?