Wayniac Posted March 26, 2010 Share Posted March 26, 2010 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 More sharing options...
hcdarkmage Posted March 26, 2010 Share Posted March 26, 2010 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 More sharing options...
Wayniac Posted March 26, 2010 Author Share Posted March 26, 2010 Well... this is a little embarrassing... Thank you for correcting my ignorance to triple check. Link to comment https://forums.phpfreaks.com/topic/196654-rounding-issue/#findComment-1032528 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.