Re: Strange basic problem with comparision of two varialbes defined as double
From: RAJ (anonymous_at_discussions.microsoft.com)
Date: 05/17/04
- Next message: Laurence: "sp6 breaks the list view"
- Previous message: Shelby: "How to set UDT as Public so that I can assess it anywhere?"
- In reply to: Duane Bozarth: "Re: Strange basic problem with comparision of two varialbes defined as double"
- Next in thread: Duane Bozarth: "Re: Strange basic problem with comparision of two varialbes defined as double"
- Reply: Duane Bozarth: "Re: Strange basic problem with comparision of two varialbes defined as double"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 17 May 2004 09:49:08 +0100
Thanks for your reply.
What alternative is there to compare two values of this sort? I have also
seen this kind of problem were in I am storing a value defined as double in
the access database field which is again defined as double with 2 decimal
places. Even though the value is, for example, 10.00, it at times (not
always) stores it as 9.99999999999997 in the database.
My application does need to compare a lot of values for accounting purposes.
Your help is much appriciated.
"Duane Bozarth" <dp_bozarth@swko.dot.net> wrote in message
news:40A77B79.7F6127E9@swko.dot.net...
> Duane Bozarth wrote:
> >
> ...snip example of floating point comparison result...
>
> > > This is giving a lot of problems in the actual code in my application.
Any
> > > help would be greatly accepted.
> >
> > http://docs.sun.com/source/806-3568/ncg_goldberg.html
> >
> > As a hint in the VB Immediate window...
> >
> > dblOne# = 41.99#
> > dblTwo# = 31.49#
> > ?dblOne#-dblTwo#
> > 7.105427357601E-15
>
> Sorry, of course the demo was <really> the following--I somehow didn't
> copy the one step...
>
> dblOne# = 41.99#
> dblTwo# = 31.49#
> dblTwo# = dblTwo# + 10.5#
> ?dblOne#-dblTwo#
> 7.105427357601E-15
>
> And, hint 2--
> <NEVER, EVER> compare two floating point values for <exact> equality
> (unless you really, really mean it (and understand fully what that
> means), of course).
- Next message: Laurence: "sp6 breaks the list view"
- Previous message: Shelby: "How to set UDT as Public so that I can assess it anywhere?"
- In reply to: Duane Bozarth: "Re: Strange basic problem with comparision of two varialbes defined as double"
- Next in thread: Duane Bozarth: "Re: Strange basic problem with comparision of two varialbes defined as double"
- Reply: Duane Bozarth: "Re: Strange basic problem with comparision of two varialbes defined as double"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|