addition of 0.7 and 0.1 is not 0.8 CDbl / CStr vbs problem



Hello Group,

i have some vbs code here and would be happy if one of you could
describe whats wrong with it.
i just would like to make addition of 0.1 and 0.7 but the result just
surprises me everytime again.
btw. i work on a system with german number format.

IF ((CDbl("0,7")+CDbl("0,1"))=(CDbl("0,8"))) THEN
MSGBOX "0,7 + 0,1 = 0,8"
ELSE
MSGBOX "0,7 + 0,1 IS NOT 0,8"
END IF

the solution for this problem is:
IF (CDbl(CStr(CDbl("0,7")+CDbl("0,1")))=(CDbl("0,8"))) THEN
MSGBOX "0,7 + 0,1 = 0,8"
ELSE
MSGBOX "0,7 + 0,1 IS NOT 0,8"
END IF

but what to hell is going on ???

kindest regards,
Robin

btw. the same prob occures with 10,7 + 0,1

.



Relevant Pages

  • Re: addition of 0.7 and 0.1 is not 0.8 CDbl / CStr vbs problem
    ... i have some vbs code here and would be happy if one of you could ... describe whats wrong with it. ... btw. i work on a system with german number format. ... Comparing floating point values should be done using a tolerance:- ...
    (microsoft.public.scripting.vbscript)
  • Re: Pro band without a "real" bass player!
    ... BTW - whats wrong with a Mustang Bass? ... I think Bill Wyman did a lot of good ...
    (alt.guitar.bass)
  • Re: Gays Plan Demonstration
    ... for those of us who aren't interes ... BTW: Whats your take on parents who throw their children out on the ...
    (alt.politics)
  • Re: addition of 0.7 and 0.1 is not 0.8 CDbl / CStr vbs problem
    ... i have some vbs code here and would be happy if one of you could ... describe whats wrong with it. ... numbers that would exceed the precision of the VBScript double: ... Justin Piper ...
    (microsoft.public.scripting.vbscript)
  • Re: changing background colour on view
    ... BTW, if you need to do this often you could easily derive your own View class and add this functionality with a function to set the color. ... "wanwan" wrote in message ... So whats wrong with it. ... I guess I'm not in luck. ...
    (microsoft.public.vc.mfc)