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


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

Re: Setting floating point variable as infinite

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Miles Bader <miles@gnu.org>
Newsgroups comp.lang.c++
Subject Re: Setting floating point variable as infinite
Date Sat, 24 Mar 2012 23:41:49 +0900
Lines 21
Message-ID <87aa36f4cy.fsf@catnip.gol.com> (permalink)
References <jkhq7k$917$1@speranza.aioe.org> <jki1h5$q44$1@dont-email.me> <jki3bh$1p7$1@speranza.aioe.org> <jki63p$mn6$1@dont-email.me> <87ty1eg70x.fsf@catnip.gol.com> <jkjfr1$5p0$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain
X-Trace individual.net DEHdvacb0SVhwAg1dLRPxQB3YnuwGut+uAMhDHswQPw9CFOiN3
Cancel-Lock sha1:W2zaYgVeQsgpYCWekkkIYYTMU5g= sha1:4bvTXHE3fydP+4VQC1UDJCtUS9k=
System-Type x86_64-unknown-linux-gnu
Xref csiph.com comp.lang.c++:15030

Show key headers only | View raw


Victor Bazarov <v.bazarov@comcast.invalid> writes:
>> It still works fine if some set element has a value of infinity...
>> (if that's the _only_ set element, then infinity is indeed the minimum;
>> if there is some smaller element, then the smaller element will win)
>
> Yes, but if infinity is allowed to be associated, and there are no
> elements in the set?

With some algorithms (calling the min function), it doesn't matter,
and it's fine to just return infinity for either case.

If it's desirable to distinguish the "empty container" case, then just
test for it first -- it's usually cheap and straight-forward to test a
container for emptiness -- and handle empty containers that way.
Note you'd have to do the _same thing_ for the method you advocated.

-miles

-- 
"Yorton, Wressle, and Gospel Oak, the richness of your heritage is ended.
We shall not stop at you again; for Dr Beeching stops at nothing."

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


Thread

Setting floating point variable as infinite Rui Maciel <rui.maciel@gmail.com> - 2012-03-23 12:27 +0000
  Re: Setting floating point variable as infinite Marc <marc.glisse@gmail.com> - 2012-03-23 12:34 +0000
    Re: Setting floating point variable as infinite glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-03-23 12:39 +0000
      Re: Setting floating point variable as infinite gwowen <gwowen@gmail.com> - 2012-03-23 06:21 -0700
      Re: Setting floating point variable as infinite Rui Maciel <rui.maciel@gmail.com> - 2012-03-23 14:39 +0000
        Re: Setting floating point variable as infinite glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-03-23 20:06 +0000
  Re: Setting floating point variable as infinite Victor Bazarov <v.bazarov@comcast.invalid> - 2012-03-23 10:32 -0400
    Re: Setting floating point variable as infinite Rui Maciel <rui.maciel@gmail.com> - 2012-03-23 15:03 +0000
      Re: Setting floating point variable as infinite Victor Bazarov <v.bazarov@comcast.invalid> - 2012-03-23 11:50 -0400
        Re: Setting floating point variable as infinite Rui Maciel <rui.maciel@gmail.com> - 2012-03-23 19:01 +0000
          Re: Setting floating point variable as infinite Christian Gollwitzer <auriocus@gmx.de> - 2012-03-23 20:26 +0100
          Re: Setting floating point variable as infinite Victor Bazarov <v.bazarov@comcast.invalid> - 2012-03-23 19:10 -0400
            Re: Setting floating point variable as infinite Rui Maciel <rui.maciel@gmail.com> - 2012-03-24 11:43 +0000
        Re: Setting floating point variable as infinite Miles Bader <miles@gnu.org> - 2012-03-24 09:46 +0900
          Re: Setting floating point variable as infinite Victor Bazarov <v.bazarov@comcast.invalid> - 2012-03-23 23:42 -0400
            Re: Setting floating point variable as infinite Rui Maciel <rui.maciel@gmail.com> - 2012-03-24 11:31 +0000
            Re: Setting floating point variable as infinite Miles Bader <miles@gnu.org> - 2012-03-24 23:41 +0900
    Re: Setting floating point variable as infinite Andrea Venturoli <ml.diespammer@netfence.it> - 2012-03-24 13:05 +0100
      Re: Setting floating point variable as infinite Victor Bazarov <v.bazarov@comcast.invalid> - 2012-03-24 15:44 -0400
  Re: Setting floating point variable as infinite Leigh Johnston <leigh@i42.co.uk> - 2012-03-24 12:30 +0000
    Re: Setting floating point variable as infinite Gareth Owen <gwowen@gmail.com> - 2012-03-25 07:52 +0100
    Re: Setting floating point variable as infinite Rui Maciel <rui.maciel@gmail.com> - 2012-03-25 12:38 +0100
      Re: Setting floating point variable as infinite Leigh Johnston <leigh@i42.co.uk> - 2012-03-25 13:36 +0100
        Re: Setting floating point variable as infinite Leigh Johnston <leigh@i42.co.uk> - 2012-03-25 14:00 +0100
          Re: Setting floating point variable as infinite Leigh Johnston <leigh@i42.co.uk> - 2012-03-25 14:05 +0100
            Re: Setting floating point variable as infinite Rui Maciel <rui.maciel@gmail.com> - 2012-03-25 16:54 +0100

csiph-web