X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: "Victor Bazarov" Newsgroups: comp.os.msdos.djgpp,comp.lang.c++ References: <142c67c0 DOT 0204092338 DOT 1ce7acb3 AT posting DOT google DOT com> Subject: Re: Weird double problem?! Lines: 33 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: <15Ss8.263184$q2.31204@sccrnsc01> NNTP-Posting-Host: 12.236.143.17 X-Complaints-To: abuse AT attbi DOT com X-Trace: sccrnsc01 1018424765 12.236.143.17 (Wed, 10 Apr 2002 07:46:05 GMT) NNTP-Posting-Date: Wed, 10 Apr 2002 07:46:05 GMT Organization: AT&T Broadband Date: Wed, 10 Apr 2002 07:46:05 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Taras" wrote... > Just doing some basic programming for maths, and something really > weird happened. I'm using RHIDE 1.4.9 w/ djgpp 2.03. I have this > line in my > program: > > const double stepSize; > stepSize = 0.1; The above code should not compile. You've declared a const without initialising it and then you're modifying a const value without any const-cast. You probably meant const double stepSize = 0.1; > when i step through the program and watch the variable step size, when > it > is assigned the value of 0.1, in the watch window it says the value is > 0.10000000000000001. I don't think it has something to do with the > displaying of the number, because when I store the result of > 1/stepSize > into an integer variable, the value of that variable is 9 (when it > should be > 10) Does anyone know where the last digit came from? From the fact that 1/10 cannot be represented _precisely_ in your computer memory. Victor -- Please remove capital A's from my address when replying by mail