Re: Rounding info needed-A2k
- From: "Ron" <ronSPAMBLOCKINGwest777@xxxxxxxxxxx>
- Date: Sat, 03 Nov 2007 18:17:45 GMT
Okay, I'm still in the dark. I've read your response and KIND of
understand. The link about 'accuracy problems' lost me at my click of it.
::grin:: (math major, I'm not!)
And, I've read the discussion between you and FMS.
However, I've still got a problem, as I see it.
I've got an operator who enters a payment to an account of 1353.57. That
amount is stored in a Number field with a Field Size of Double. Decimal
Places = Auto. It's not divided by anything...just entered as 1353.57 and
my program multiplies by -1 so it's a negative number and on to the next
payment. But, instead of saving the entered amount -1353.57, it's stores
something like -1353.569999999999999988832982929828 (etc).
Or, -1353.570000000000000000000002737387237732 (etc).
Who decided it should be something other than -1353.57? The data type? Or,
did my multiplying the input number (a positive number) by -1 do the nasty
deed of making it a minus 1353.5699999999999(etc)?
And how do I get it stored as -1353.57 (exactly as input rather than this
bazaar desire of whatever to be so accurate I could use it to build a DNA
example)?
I'll NEVER need a field saved that's the result of dividing something by
something else (ex 1353.57 / 9 = 150.841111282817171761 or whatever).
Perhaps in a report I'd do something like that, but I'd not need to save it
anywhere (as far as I know). And, if I do it in a report or whatnot, I can
see doing the round() function now that I know of this bazaar desire to be
accurate out to 82 million digits (or, whatever). But, all I'm trying to do
is store an accurate negative amount (accurate to me is what was input) that
is, in fact, dollars and cents.
I chose the number/double type over the currency because I didn't like the
dollar signs appearing all over the place. Perhaps that was my error? I
now realize I could have used the currency type and then standard format, or
whatever. But, it's a done deal...unless I change the type, which I guess I
could do. But, is that necessary to get what I'm trying to get?
Second to the last paragraph of your response seems to indicate I'll still
need to do the round() function prior to saving the data input to the
approrpiate field. Where do I do that?
Thanks much for all the info...and sorry I'm seeming so dense (perhaps I
am...).
ron
"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:472a6954$0$17164$5a62ac22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
There are a couple of factors that contribute to this issue, Ron.<snipped my original post>
The first is the field type. If you use a Number field (size Double or
Single), you have a floating point data type. This is really useful for
handling enormous numbers (+/- numbers with millions of billions) or
miniscule numbers (hundreds of zeros after the decimal point before the
digits really start), but they are limited to around 15 significant digits
(for a Double.) Most fractional numbers cannot be stored precisely in this
binary form, just as many numbers (such as 1/7 or 1/3) cannot be stored
precisely in the decimal form without an infinite number of digits.
Consequently, floating point numbers always have these rounding problems.
For more details, see:
http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
One solution is to use a fixed point data type instead of a floating
point. The Currency type in Access does this. It stores the number as if
it were an 8-byte integer, and then adds the decimal point 4-digits from
the right. This arrangement means that the 4 digits to the right of the
decimal point are precise. The disadvantage is that it is not suitable for
numbers where more than 4 digits are required, or for really enormous
numbers. This is ideal for most currencies. It is also useful for other
scenarios (e.g. to store precise distances in metres, with a resolution
down to 1/10 mm.)
Your example wanted only 2 decimal places. The Currency format typically
shows 2, though it stores 4. Therefore you will need to use Round() when
performing calcuations that write a value so the Currency field, so ensure
the last 2 digits are stored as zeros. If you want to display the currency
field as fixed to 2 decimal places (not dollars and cents), set its Format
property to Fixed, and the Decimal Places to 2.
There is another data type in Access: a Number field of size Decimal. This
is a scalar data type. It is similar to the fixed point, but you can
specify where the decimal point goes for any particular field (unlike the
Currency field, where it is always 4 digits.) While this is a great
concept, unfortunately the implementation in Access is buggy, so I can't
recommend using it. Here's one example of why:
http://allenbrowne.com/bug-08.html
--
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.
.
- Follow-Ups:
- Re: Rounding info needed-A2k
- From: Larry Linson
- Re: Rounding info needed-A2k
- References:
- Rounding info needed-A2k
- From: Ron
- Re: Rounding info needed-A2k
- From: Allen Browne
- Rounding info needed-A2k
- Prev by Date: Re: What are macros in A2003?
- Next by Date: Re: Default use Specific Printer and Label Size
- Previous by thread: Re: Rounding info needed-A2k
- Next by thread: Re: Rounding info needed-A2k
- Index(es):
Relevant Pages
|