[AccessD] Rounding Error - A2K

Reuben Cummings accessd at gfconsultants.com
Fri Dec 11 11:01:46 CST 2009


My question is...
What data type is the result of your equation?

I understant multiplying by 100 before converting to Currency in order to
maintain all the decimals.
However, when you divide by 100 what's the result?  If it stayed currency
wouldn't you lose two of the decimals?

Reuben Cummings
GFC, LLC
812.523.1017


> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com 
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of 
> Gustav Brock
> Sent: Friday, December 11, 2009 10:59 AM
> To: accessd at databaseadvisors.com
> Subject: Re: [AccessD] Rounding Error - A2K
> 
> 
> Hi Reuben
> 
> What a relief! Thanks for the feedback!
> 
> /gustav
> 
> 
> >>> accessd at gfconsultants.com 11-12-2009 16:50 >>>
> Nope.  Just did it again and you're right.  Yours works fine.
> I must have misplaced something when I was trying it Wednesday night.
> Sorry.
> 
> Thanks, Gustav.
> 
> Reuben Cummings
> GFC, LLC
> 812.523.1017
> 
> 
> > -----Original Message-----
> > From: accessd-bounces at databaseadvisors.com 
> > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of 
> > Gustav Brock
> > Sent: Thursday, December 10, 2009 8:45 AM
> > To: accessd at databaseadvisors.com 
> > Subject: Re: [AccessD] Rounding Error - A2K
> > 
> > 
> > Hi Reuben
> > 
> > I did some tests with no errors and returning the correct 
> > data type. Are you sure about this?
> > 
> > /gustav
> > 
> > 
> > >>> accessd at gfconsultants.com 10-12-2009 12:57 >>>
> > Thanks.  That appears to work.  However, I think your 
> > paranthesis are off.
> > For anyone wanting this for future use I had to change it to...
> > 
> > >   CurResult = CCur((CurAmount * CCur(100 * SngPercentage))/ 100)
> > 
> > Only added two paranthesis (to completely inclose the 
> > multiplication part),
> > but it makes sure the math gets done before it gets divided by 100.
> > 
> > Thanks for the help.
> > 
> > Reuben Cummings
> > GFC, LLC
> > 812.523.1017
> > 
> > 
> > > -----Original Message-----
> > > From: accessd-bounces at databaseadvisors.com 
> > > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of 
> > > Gustav Brock
> > > Sent: Thursday, December 10, 2009 4:18 AM
> > > To: accessd at databaseadvisors.com 
> > > Subject: Re: [AccessD] Rounding Error - A2K
> > > 
> > > 
> > > Hi Reuben
> > > 
> > > There is your explanation: cur * sng returns a double.
> > > 
> > > What you could do is to keep storing the percentage as a 
> > > single. When using it for calculation, do:
> > > 
> > >   CurResult = CCur(CurAmount * CCur(100 * SngPercentage) / 100)
> > > 
> > > This will calculate using your six decimals and (with CCur) 
> > > round the result to four decimals.
> > > 
> > > /gustav
> 
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 






More information about the AccessD mailing list