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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.