Forum Discussion

Raveees's avatar
Raveees
Occasional Contributor
3 years ago

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 si...
  • rraghvani's avatar
    3 years ago

    For example (JavaScript),

     

     

    function test()
    {
        var a = 2.85;
        var b = 2.8;
        var diff = a - b;
        Log.Message(diff.toFixed(2));
    }