[AccessD] Round function strangeness

Gustav Brock gustav at cactus.dk
Wed Jan 24 11:51:38 CST 2018


Hi Bill and Doug

Oh, missed that. 
However, I checked with the same values in a query using fields of Single.
Same results as in VBA.

/gustav

-----Oprindelig meddelelse-----
Fra: AccessD [mailto:accessd-bounces at databaseadvisors.com] På vegne af Bill Benson
Sendt: 24. januar 2018 18:36
Til: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Emne: Re: [AccessD] Round function strangeness

Doug had an issue in a query not in VBA.

On Jan 24, 2018 1:58 AM, "Gustav Brock" <gustav at cactus.dk> wrote:

Hi Doug

A random sample works as expected here:

a = CSng(15.17345)
b = CSng(23.23498)
? a, b, Round(a * b + 1, 1), Round(a * b, 1)
 15.17345      23.23498      353.6         352.6

But Round is known to be buggy, though I haven't met the scenario you scenario you describe.
Could you provide some of your value sets, please?

And - thanks Jack - for any serious use of rounding, I strongly recommend using my rounding functions that will never fail:

https://www.experts-exchange.com/articles/20299/Rounding-values-up-down-by-4-5-or-to-significant-figures.html

or:

https://www.codeproject.com/Tips/1022704/Rounding-Values-Up-Down-By-Or-To-Significant-Figur

/gustav

-----Oprindelig meddelelse-----
Fra: AccessD [mailto:accessd-bounces at databaseadvisors.com] På vegne af Doug Steele
Sendt: 23. januar 2018 19:13
Til: Access Developers discussion and problem solving < accessd at databaseadvisors.com>
Emne: [AccessD] Round function strangeness

I used the Round function in a query that had 2 calculated fields. The first one was a calculation like a*b+1, the second a straight
multiplication: a*b. The output from Round(a*b+1,1) was correctly rounded to one decimal place. The output from Round(a*b,1) wasn't rounded off at all. But when (in desperation), I changed this to Round(a*b+1-1,1), which is ridiculous, the output was rounded off correctly!

Any comments?

Doug 



More information about the AccessD mailing list