[AccessD] Is this a bug in Access' implementation of the Single data ty pe?

Heenan, Lambert Lambert.Heenan at AIG.com
Fri Mar 17 16:29:07 CST 2006


But according to the on-line help (which I quoted) a Single can hold numbers
in the range

"-3.402823E38 to -1.401298E-45 for negative values and from 1.401298E-45 to
3.402823E38 for positive values".

And this range is confirmed by
http://msdn2.microsoft.com/en-us/library/xay7978z(VS.80).aspx

PowerBasic uses a similar (but different) range 
http://www.powerbasic.com/support/help/pbcc/single-precision_floating-point_
(!).htm

... Cogitate...cogitate...

Ah, I see. So you only get 7 significant decimal digits in value, and when
you enter more (up to the limit of x^38) it will be rounded.

Thanks.

Lambert

-----Original Message-----
From: Microsoft Access Database Discussion List
[mailto:ACCESS-L at PEACH.EASE.LSOFT.COM] On Behalf Of ysiebeneck at UPS.COM
Sent: Friday, March 17, 2006 4:58 PM
To: ACCESS-L at PEACH.EASE.LSOFT.COM
Subject: Re: Is this a bug in Access' implementation of the Single data
type?


This is the standard and expected behavior of a single data type.  To be
more precise, a single-precision 32-bit data type.

666,656,666 = 6.66656666E+08.  However, the single data type can only store
6.666566E+08, which is 666,656,600 -  which is what was observed. You have
to remember to account for the precision part of the single-precision data
type.

Single data types are stored in the 0.000000E+-00 format, with 8 of the bits
storing the exponent, one the sign, and the remaining 23 bits the fraction.

If you want a more in depth explanation, do a google search with "IEEE
32-bit single-precision floating-point".

Yon-Paul


-----Original Message-----
From: Microsoft Access Database Discussion List
[mailto:ACCESS-L at PEACH.EASE.LSOFT.COM] On Behalf Of Heenan, Lambert
Sent: Friday, March 17, 2006 2:01 PM
To: ACCESS-L at PEACH.EASE.LSOFT.COM
Subject: Is this a bug in Access' implementation of the Single data type?


I've forwarded this message from the AccessD list for your information and
comments.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, Lambert
Sent: Friday, March 17, 2006 3:17 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Single vs. double issue...


The difference between Single and Double is not just the number of decimal
places, but also the range of values to the left of the decimal point.

A Single can store -3.402823E38 to -1.401298E-45 for negative values and
from 1.401298E-45 to 3.402823E38 for positive values. 

A Double can store -1.79769313486231E308 to -4.94065645841247E-324 for
negative values and from 4.94065645841247E-324 to 1.79769313486232E308 for
positive values. 

That's the official word. I just tested what you report and can confirm that
singles in a table are doing this very strange 'rounding'. It also happened
when you use Single type variables in code. It makes no sense at all to me
as 666,656,666 is only ~6.66E8, well within the supposed range of a Single.

So at first blush this is a VERY SERIOUS bug in the Single data type!!!!!!!

Anyone care to ring the bell at M$?

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bobby Heid
Sent: Friday, March 17, 2006 2:54 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Single vs. double issue...


Hey,

I always thought that the main difference between a single and a double was
that the single had 7 digits  and the double had 15 digits of precision
AFTER the decimal point.

Normally, I store decimal values as double.  But for some reason, this
particular field was set to single.  Our client found an issue with that
field today.  They had entered 666,656,666 into the field.  When you look at
the table, it is 666,656,600.

As a test, I changed the field to double, entered 666,656,666, and saved it.
The value stuck.  Then I changed it to single, got the smaller field size
warning, and saved it.  When I looked at the table, the value was
666,656,600.

So, I think the issue is that I misunderstood what the precision meant in
the single vs. double declaration.  I wanted to be sure that this was the
issue before I just blindly convert them to doubles.  Am I correct?

Thanks,
Bobby

--------------------------------------------------------------------------
The ACCESS-L list is hosted on a Windows(R) 2000 Server running L-Soft
international's LISTSERV(R) software.  For subscription/signoff info and
archives, see http://peach.ease.lsoft.com/archives/access-l.html .
                             COPYRIGHT INFO:
http://peach.ease.lsoft.com/scripts/wa.exe?SHOWTPL=COPYRIGHT&L=ACCESS-L



More information about the AccessD mailing list