public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Paul D. DeRocco" <pderocco@ix.netcom.com>
To: "eCos Discuss" <ecos-discuss@ecos.sourceware.org>
Subject: RE: [ECOS] One question.
Date: Wed, 31 May 2006 06:28:00 -0000	[thread overview]
Message-ID: <NEBBKHCFDGIGIJEHDJFCGEKHEIAB.pderocco@ix.netcom.com> (raw)
In-Reply-To: <F7DDB0A5340F2D47966F7AD8DF5447E3013427DD@INC-MX8.inc.iac>

> From: Zhao.Green@inventec-inc.com
>
> 	I use the ecos package , and I found the double type question
> Double dnum1 = 1234567.1
> Double dnum2 = 1234567
> Double result = 0 ;
>
> Result = dnum1-dnum2 ;
>
> The result is 0.10000000009
>
> Anybody know how to solve this question?

0.1 can't be represented exactly in binary, so there's an inevitable
roundoff error. Sometimes these errors are hidden by the implementation of
the binary to decimal conversion used in printing out the answer, but
sometimes not. I don't know if you're using printf in C, or << in C++, but
you might try requesting less precision in the output, to see if that rounds
the result back to 0.1.

--

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

  parent reply	other threads:[~2006-05-31  6:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-31  5:15 Zhao.Green
2006-05-31  6:12 ` Fabian Scheler
2006-05-31  6:28 ` Paul D. DeRocco [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-05-31  6:50 Zhao.Green
2006-05-31  7:58 ` Michele Portolan
2006-05-31 11:49   ` Edgar Grimberg
2004-06-25  8:09 anton yakovlev
2004-06-25 11:28 ` Gary Thomas
2004-06-26  8:59   ` anton yakovlev
2004-06-26 11:50     ` Gary Thomas
2004-06-26 12:26       ` anton yakovlev
2004-06-26 12:31         ` Gary Thomas
2004-06-26 15:40           ` anton yakovlev
     [not found] ` <40DBE222.8040603@codito.com>
2004-06-26  8:49   ` anton yakovlev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=NEBBKHCFDGIGIJEHDJFCGEKHEIAB.pderocco@ix.netcom.com \
    --to=pderocco@ix.netcom.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).