Re: problem assigning double as defaultvalue
From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 04/24/04
- Previous message: Alexander Nickolov: "Re: ATL Control in VB"
- In reply to: Sascha Herpers: "Re: problem assigning double as defaultvalue"
- Next in thread: Sascha Herpers: "Re: problem assigning double as defaultvalue"
- Reply: Sascha Herpers: "Re: problem assigning double as defaultvalue"
- Reply: Simon Trew: "Re: problem assigning double as defaultvalue"
- Reply: Kirill Stoimenov: "Re: problem assigning double as defaultvalue"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 23 Apr 2004 23:28:26 -0700
It's more like ignorance on you part really... This behavior is
by design - floating point arithmetics is imprecise. You should
never compare floating point numbers directly (especially the
results of computations). Have you studied interval arithmetics?
What about computational methods? You should have studied
about error accumulation... Anyway, the point is, you should
compare two floating point numbers by subtracting them and
comparing the absolute of the difference against your precision
threshold. If it is under the threshold, the numbers are the same,
otherwise they differ.
-- ===================================== Alexander Nickolov Microsoft MVP [VC], MCSD email: agnickolov@mvps.org MVP VC FAQ: http://www.mvps.org/vcfaq ===================================== "Sascha Herpers" <formefromnews@brainpowered.de> wrote in message news:c6bavj$a8mkg$1@ID-144102.news.uni-berlin.de... > > Looks like it gets stored as float somewhere along the line, either in > > the TLB or in MIDL internal structures. Or, MIDL has problem accurately > > parsing floating point literals. You see, double gives you precision to > > about 15 decimal digits, and float provides only 7-8. The number you get > > from default value is accurate to 7 decimal digits. > I see. That's probably the reason why casting it to double like this: > defaultvalue((double) 0.00001) > gave a totally different result. MIDL seems to somehow misinterprete the > constant... > > Oh well...just another thing I will mark as "don't worry about it, you > can't change it anyways" kind of thing... :( > > Thanks Igor. > Sash
- Previous message: Alexander Nickolov: "Re: ATL Control in VB"
- In reply to: Sascha Herpers: "Re: problem assigning double as defaultvalue"
- Next in thread: Sascha Herpers: "Re: problem assigning double as defaultvalue"
- Reply: Sascha Herpers: "Re: problem assigning double as defaultvalue"
- Reply: Simon Trew: "Re: problem assigning double as defaultvalue"
- Reply: Kirill Stoimenov: "Re: problem assigning double as defaultvalue"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|