Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #13663

Re: comparing floating point numbers

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.albasani.net!.POSTED!not-for-mail
From Thomas Boell <tboell@domain.invalid>
Newsgroups comp.lang.c++
Subject Re: comparing floating point numbers
Date Mon, 30 Jan 2012 16:29:12 +0100
Organization albasani.net
Lines 26
Message-ID <20120130162912.0b18f547@arcadia> (permalink)
References <jg44ad$fti$1@news.icm.edu.pl> <4f25d682$0$15922$cc2e38e6@news.uslec.net>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net LLqUuG1+K4YvSAEDMZTbvpOGvz0hLMqf9FkRJ8ONMur9OaFJpWe+ZzZ8a+wnQHE2NaqUtmiznyTq3E+LHg8+wxEOz86AgX5LOHZak5ryCVzo1qwjXyEy7Q5Vfy1xXlhZ
NNTP-Posting-Date Mon, 30 Jan 2012 15:29:12 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="gHjdrlnV613R568ZyzdW/TXiaFGjvMBwLat9StKI6+PjFHLZefsltmx5tjE8YxL2moAyMyfSkEyaX6Xw385oJM+rQFTRJQ4qK6xlMRpnYgfYOfdHmQ54y1x3y4fWoBDr"; mail-complaints-to="abuse@albasani.net"
X-Newsreader Claws Mail 3.7.8 (GTK+ 2.24.4; i686-pc-linux-gnu)
Cancel-Lock sha1:vOssP9V60kgayS4IFWQV32AhTpY=
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:13663

Show key headers only | View raw


On Sun, 29 Jan 2012 18:30:06 -0500
LR <lruss@superlink.net> wrote:

> Adam Majewski wrote:
> 
> > I have seen code that compers like that :
> > 
> > if (b == 0.0  && (a == 0.25 || a == -0.75))
> 
> 
> I suggest these two articles in the FAQ
> http://www.parashift.com/c++-faq-lite/index.html
> 
> [29.16] Why is floating point so inaccurate? Why doesn't this print 0.43?
> http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.16
> 
> Perhaps more relevant to your question and with some interesting references.
> [29.17] Why doesn't my floating-point comparison work?
> http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17

Another very informative article about this topic is this one:

Comparing floating point numbers - Bruce Dawson
http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

comparing floating point numbers Adam Majewski <adammaj1@o2.pl> - 2012-01-29 19:48 +0100
  Re: comparing floating point numbers BCFD36 <bcfd36@cruzio.com> - 2012-01-29 11:02 -0800
    Re: comparing floating point numbers "MikeWhy" <boat042-nospam@yahoo.com> - 2012-01-29 13:25 -0600
      Re: comparing floating point numbers "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-01-29 20:40 +0100
    Re: comparing floating point numbers Adam Majewski <adammaj1@o2.pl> - 2012-01-30 18:03 +0100
  Re: comparing floating point numbers Marcel Müller <news.5.maazl@spamgourmet.com> - 2012-01-29 21:34 +0100
    Re: comparing floating point numbers BCFD36 <bcfd36@cruzio.com> - 2012-01-29 14:55 -0800
      Re: comparing floating point numbers Miles Bader <miles@gnu.org> - 2012-01-30 11:48 +0900
        Re: comparing floating point numbers Juha Nieminen <nospam@thanks.invalid> - 2012-01-30 14:53 +0000
    Re: comparing floating point numbers scott@slp53.sl.home (Scott Lurndal) - 2012-01-30 17:22 +0000
      Re: comparing floating point numbers Robert Wessel <robertwessel2@yahoo.com> - 2012-01-30 13:55 -0600
      Re: comparing floating point numbers glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-02-13 01:56 +0000
  Re: comparing floating point numbers LR <lruss@superlink.net> - 2012-01-29 18:30 -0500
    Re: comparing floating point numbers Thomas Boell <tboell@domain.invalid> - 2012-01-30 16:29 +0100
  Re: comparing floating point numbers Christian Gollwitzer <auriocus@gmx.de> - 2012-01-30 08:07 +0100
    Re: comparing floating point numbers glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-02-13 01:59 +0000
  Re: comparing floating point numbers Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-30 06:26 -0800

csiph-web