A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Best Data Type for up to 12-digit Accuracy (up to 9 after dec poin



 
 
Thread Tools Display Modes
  #1  
Old April 2nd, 2009, 11:09 PM posted to microsoft.public.access.tablesdbdesign
SH2008
external usenet poster
 
Posts: 3
Default Best Data Type for up to 12-digit Accuracy (up to 9 after dec poin

Hi there--

I need to store numeric data that should be able to handle up to 12 digits
with up to 9 digits behind the decimal point. Thus, Currency is out and
Double seems the only data type in Access capable of handling this many
digits. I was informed, however, that Access (sometimes?) creates "ghost
digits" for double numbers -- extra random digits after the last digit.

Assuming that I enter a bunch of percentage numbers with up to 9 decimal
digits totaling 100%, my application CAN NOT EVER have rounding errors that
would cause the sum of the numbers to vary from 100.000000000% exactly.

What scenario would you guys recommend for this requirement?

Thanks!
  #2  
Old April 3rd, 2009, 12:07 AM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Best Data Type for up to 12-digit Accuracy (up to 9 after dec poin

On Thu, 2 Apr 2009 15:09:01 -0700, SH2008
wrote:

Hi there--

I need to store numeric data that should be able to handle up to 12 digits
with up to 9 digits behind the decimal point. Thus, Currency is out and
Double seems the only data type in Access capable of handling this many
digits. I was informed, however, that Access (sometimes?) creates "ghost
digits" for double numbers -- extra random digits after the last digit.

Assuming that I enter a bunch of percentage numbers with up to 9 decimal
digits totaling 100%, my application CAN NOT EVER have rounding errors that
would cause the sum of the numbers to vary from 100.000000000% exactly.

What scenario would you guys recommend for this requirement?

Thanks!


There are (or were, they may have been fixed in a service pack) some quirks
about sorting negative numbers in the Decimal datatype - but I'd give it a
try. Set the Precision to 12 and the Scale to 9 (precision can be up to 18 I
believe).
--

John W. Vinson [MVP]
  #3  
Old April 3rd, 2009, 12:31 AM posted to microsoft.public.access.tablesdbdesign
SH2008
external usenet poster
 
Posts: 3
Default Best Data Type for up to 12-digit Accuracy (up to 9 after dec

Thank you, John.

I thought 'decimal' is not native to Access and gets converted to double for
calculations via VBA. Would I not end up with the same problem?

"John W. Vinson" wrote:

On Thu, 2 Apr 2009 15:09:01 -0700, SH2008
wrote:

Hi there--

I need to store numeric data that should be able to handle up to 12 digits
with up to 9 digits behind the decimal point. Thus, Currency is out and
Double seems the only data type in Access capable of handling this many
digits. I was informed, however, that Access (sometimes?) creates "ghost
digits" for double numbers -- extra random digits after the last digit.

Assuming that I enter a bunch of percentage numbers with up to 9 decimal
digits totaling 100%, my application CAN NOT EVER have rounding errors that
would cause the sum of the numbers to vary from 100.000000000% exactly.

What scenario would you guys recommend for this requirement?

Thanks!


There are (or were, they may have been fixed in a service pack) some quirks
about sorting negative numbers in the Decimal datatype - but I'd give it a
try. Set the Precision to 12 and the Scale to 9 (precision can be up to 18 I
believe).
--

John W. Vinson [MVP]

  #4  
Old April 3rd, 2009, 12:55 AM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Best Data Type for up to 12-digit Accuracy (up to 9 after dec

On Thu, 2 Apr 2009 16:31:28 -0700, SH2008
wrote:

Thank you, John.

I thought 'decimal' is not native to Access and gets converted to double for
calculations via VBA. Would I not end up with the same problem?


I don't know. Crystal has raised this same issue off the newsgroups, I'll post
back when I learn more!
--

John W. Vinson [MVP]
  #5  
Old April 3rd, 2009, 07:31 AM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default Best Data Type for up to 12-digit Accuracy (up to 9 after dec

The Decimal is a scalar data type, where you can set the number of decimal
places you want at the table level.

In VBA, you can create a Variant, and typecast a value with CDec(). I expect
that the result of operating on two variants of subtype Decimal would be a
Decimal, but that's without testing. Perhaps you would like to test it with
different operators and see what you find. This kind of thing:
Dim var1 As Variant
Dim var2 As Variant
var1 = CDec(99.123456789)
var2 = CDec(88.123456789)
Debug.Print VarType(var1 + var2)

Of course you can't set the scalar level in VBA. Again, I really don't know
if this will do any good, but you could try giving it some, e.g.:
var1 = CDec(2.000000001) - CDec(0.000000001)

JET does have some issues handling with decimals, e.g.
http://allenbrowne.com/bug-08.html

In other words, run some tests, Crystal, and have fun!

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"SH2008" wrote in message
...
Thank you, John.

I thought 'decimal' is not native to Access and gets converted to double
for
calculations via VBA. Would I not end up with the same problem?

"John W. Vinson" wrote:

On Thu, 2 Apr 2009 15:09:01 -0700, SH2008

wrote:

Hi there--

I need to store numeric data that should be able to handle up to 12
digits
with up to 9 digits behind the decimal point. Thus, Currency is out and
Double seems the only data type in Access capable of handling this many
digits. I was informed, however, that Access (sometimes?) creates "ghost
digits" for double numbers -- extra random digits after the last digit.

Assuming that I enter a bunch of percentage numbers with up to 9 decimal
digits totaling 100%, my application CAN NOT EVER have rounding errors
that
would cause the sum of the numbers to vary from 100.000000000% exactly.

What scenario would you guys recommend for this requirement?

Thanks!


There are (or were, they may have been fixed in a service pack) some
quirks
about sorting negative numbers in the Decimal datatype - but I'd give it
a
try. Set the Precision to 12 and the Scale to 9 (precision can be up to
18 I
believe).
--

John W. Vinson [MVP]


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:43 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.