delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/04/10/04:32:18

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Message-ID: <3cb3f13a@newsflash.abo.fi>
From: Jukka-Pekka Suominen INF <jusuomin AT abo DOT fi>
Subject: Re: Weird double problem?!
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++
Followup-To: comp.os.msdos.djgpp
Date: Wed, 10 Apr 2002 11:00:04 +0300
References: <142c67c0 DOT 0204092338 DOT 1ce7acb3 AT posting DOT google DOT com>
Lines: 21
User-Agent: KNode/0.6.1
MIME-Version: 1.0
NNTP-Posting-Host: pingvin0.abo.fi
X-Original-NNTP-Posting-Host: pingvin0.abo.fi
X-Trace: newsflash.abo.fi 1018425658 pingvin0.abo.fi (10 Apr 2002 11:00:58 +0200)
XPident: jusuomin
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Taras wrote:

>   stepSize = 0.1;
>don't think it has something to do with the
> displaying of the number, because when I store the result of
> 1/stepSize

Here you should use 1.0/stepSize instead of 1 to perform a floating point 
division instead of an integer division.

> 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?

It comes from the binary representation of 0.1 decimal. This value cannot 
be accurately represented as a binary value (powers of two), so instead you 
get an approximation.


-- 
Jukka-Pekka Suominen

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019