Raveees
3 years agoOccasional Contributor
Converting Float to String with decimal length
I am subtracting 2 values var diff = (2.85 - 2.8) - These values are captured from a screen and converted from a string to Float
Now the diff shows as 0.050000000000026.
How do I cut the size of above diff value to 2 decimals ( 0.50) ?
I have tried to convert the diff from Float to String but it showing as "5.000000000003E-02"
Any help with decimal positions in Float or exact conversion of Float to Str ?
I am using TestComplete Version: 14.73.382.7 x64
For example (JavaScript),
function test() { var a = 2.85; var b = 2.8; var diff = a - b; Log.Message(diff.toFixed(2)); }