Quantcast
Channel: Classic ASP
Viewing all articles
Browse latest Browse all 488

classic ASP giving a wrong answer to a maths calc!

$
0
0

Hi, Can anyone give me a work-around for this please?

If you have a classic ASP page with the following:

<% response.write 1.0668 - 1.01885 &"<br>" %>

This 'should' give you the answer of:

0.04795

but in reality gives:

4.79499999999999E-02

Through experimentation I can see that the issue relates to the number of decimal places in the second number AND that fact it ends in a five.  (If I change that end number from a 5 to a 4 for example -it works it out correctly.  Also, if I reduce the number of decimal places in the second number (but still have it ending with a 5), again, it works out it correctly.

So the 'bug' appears to be related to a number with "at least" 5 decimal places ending in a 5.

I've tried the usual cdbl() and formatnumber() without any success.


Viewing all articles
Browse latest Browse all 488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>