Normal Topic Rounding error (Read 1334 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Rounding error
Feb 1st, 2010 at 9:14pm
Print Post Print Post  
I have a field on my Invoice for for Equipment charges.  Our rate for these is $14.50 an hour.  Recently a job took 2.75 hours ($14.50 * 2.75 = $39.875).   The record on screen shows the result as $39.88, but the invoice prints as $39.87.  What is the best way to fix this?  Thanks for your help.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Rounding error
Reply #1 - Feb 1st, 2010 at 10:08pm
Print Post Print Post  
Are you using @Decimals or @Round when printing?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Rounding error
Reply #2 - Feb 2nd, 2010 at 1:12pm
Print Post Print Post  
@Decimals().  I use @Round() in two places in my programming: when I calculate a customer discount and when I calculate the invoice total.  But the print routine is filled with @Decimals().
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Rounding error
Reply #3 - Feb 2nd, 2010 at 2:30pm
Print Post Print Post  
Infinity wrote on Feb 2nd, 2010 at 1:12pm:
@Decimals().  I use @Round() in two places in my programming: when I calculate a customer discount and when I calculate the invoice total.  But the print routine is filled with @Decimals().

@Decimals does not round. It truncates.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Rounding error
Reply #4 - Feb 2nd, 2010 at 2:38pm
Print Post Print Post  
So.....  I should be using both in the print routine?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Rounding error
Reply #5 - Feb 2nd, 2010 at 3:16pm
Print Post Print Post  
@Decimals just truncates the data and doesn't round. You can go about fixing this one of two ways. One way would be to use @Round when printing. The other is to make the stored value $39.88 instead of the unrounded $39.875 by using @Round when it is calculated and set.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Rounding error
Reply #6 - Feb 2nd, 2010 at 3:25pm
Print Post Print Post  
Thanks.  I think I'll use the calculation route so it's stored correctly, and use @DefinedRound (up).  How does that sound?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Rounding error
Reply #7 - Feb 2nd, 2010 at 4:12pm
Print Post Print Post  
Sounds good.
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Rounding error
Reply #8 - Feb 2nd, 2010 at 4:29pm
Print Post Print Post  
Thanks guys.  I've reprogrammed all my money calculation @ROUNDs as @DEFINEDROUNDs, rounding up.  Program editor seems happy, I'll know tomorrow if I broke anything when I reconcile.

BTW, the only calculation programming that I didn't have @Round applying to was some stuff I had split off into an SBAS file....specifically the equipment charge, which is the one that got me into this mess in the first place.  D'oh.

Thanks for your help.
  

**
Captain Infinity
Back to top
IP Logged