Jump to content

Rounding Issue...


Wayniac

Recommended Posts

This issue I am having is it seems every time this calculation is made on whatever the value may be, its always off by either a positive several cents or a negative several cents. I tracked the reason down to it not rounding to the nearest 10. Thus resulting in a bunch of random decimals being calculated together instead of rounded and then calculated...

 

In this case, the end value should be 31.04, but instead its 31.43.

 

FYI: Variable v1 = 1 in this circumstance...

 

document.getElementById("txt_price2").value = v1 * 24.95 * 1.0795 + 9.50 - 5.00;

 

Really appreciate some way in getting this to round off properly...

Link to comment
https://forums.phpfreaks.com/topic/196654-rounding-issue/
Share on other sites

 

In this case, the end value should be 31.04, but instead its 31.43.

 

FYI: Variable v1 = 1 in this circumstance...

 

document.getElementById("txt_price2").value = v1 * 24.95 * 1.0795 + 9.50 - 5.00;

 

Really appreciate some way in getting this to round off properly...

 

Apparently, it is rounding off properly, unless I read the equation wrong. According to my calculator, my result is 31.433525, essentially 31.43.

Link to comment
https://forums.phpfreaks.com/topic/196654-rounding-issue/#findComment-1032503
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.