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


Groups > comp.lang.python > #65055

Re: 1 > 0 == True -> False

References (3 earlier) <roy-362954.09085830012014@news.panix.com> <52ea6b0f$0$29972$c3e8da3$5496439d@news.astraweb.com> <7b41606f-4027-4470-b158-62f81b4e945c@googlegroups.com> <mailman.6158.1391108625.18130.python-list@python.org> <a10e3fc2-0e79-4da8-ad80-63d75a2a2ade@googlegroups.com>
Date 2014-01-31 09:29 +1100
Subject Re: 1 > 0 == True -> False
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.6170.1391120955.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Jan 31, 2014 at 9:09 AM, Roy Smith <roy@panix.com> wrote:
> On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote:
>> `(x+1 > 0) and (y >= 5)`
>
> Me:
>> this is even simpler:
>> (x > -1) and (y >= 5)
>
> On Thursday, January 30, 2014 2:03:42 PM UTC-5, Chris Angelico wrote:
>> Be careful; that's not the same thing.
>
> In what way?  I'm assuming x is some numeric type.  And further assuming it's not some humungous floating point value, so we run into precision issues.

Now you're changing the problem domain :) Like I said, if it's an
integer, you definitely will get the same result from each of the
above; but that doesn't mean the expressions are equivalent. They just
might happen to produce the same result for values within some
particular domain. (I wouldn't even be 100% confident that it's valid
for any numeric type, though I can't think of any float values that it
would break on, and complex and int are unorderable anyway.)

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

1 > 0 == True -> False Thibault Langlois <thibault.langlois@gmail.com> - 2014-01-30 03:36 -0800
  Re: 1 > 0 == True -> False Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2014-01-30 12:44 +0100
  Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 13:46 +0200
    Re: 1 > 0 == True -> False Peter Otten <__peter__@web.de> - 2014-01-30 13:04 +0100
      Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 14:08 +0200
  Re:1 > 0 == True -> False Dave Angel <davea@davea.name> - 2014-01-30 07:49 -0500
    Re: 1 > 0 == True -> False Thibault Langlois <thibault.langlois@gmail.com> - 2014-01-30 05:40 -0800
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 00:55 +1100
      Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 09:08 -0500
        Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 01:18 +1100
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 09:49 -0500
            Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 02:02 +1100
        Re: 1 > 0 == True -> False Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-01-30 06:41 -0800
        Re: 1 > 0 == True -> False Thibault Langlois <thibault.langlois@gmail.com> - 2014-01-30 06:46 -0800
          Re: 1 > 0 == True -> False Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-30 17:42 +0000
        Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 16:56 +0200
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 10:46 -0800
            Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 22:14 +0200
              Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 07:25 +1100
        Re: 1 > 0 == True -> False Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-30 15:09 +0000
          Re: 1 > 0 == True -> False Rustom Mody <rustompmody@gmail.com> - 2014-01-30 07:34 -0800
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 10:53 -0800
            Re: 1 > 0 == True -> False Rustom Mody <rustompmody@gmail.com> - 2014-01-30 19:33 -0800
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 10:56 -0800
            Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 06:03 +1100
              Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 14:09 -0800
                Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 09:29 +1100
            Re: 1 > 0 == True -> False Ethan Furman <ethan@stoneleaf.us> - 2014-01-30 11:22 -0800
            Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 06:48 +1100
    Re: 1 > 0 == True -> False Rotwang <sg552@hotmail.co.uk> - 2014-01-30 19:25 +0000
      Re: 1 > 0 == True -> False Dave Angel <davea@davea.name> - 2014-01-30 15:08 -0500
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 07:15 +1100
      Re: 1 > 0 == True -> False Ian Kelly <ian.g.kelly@gmail.com> - 2014-01-30 13:28 -0700
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 07:38 +1100
      Re: 1 > 0 == True -> False Ian Kelly <ian.g.kelly@gmail.com> - 2014-01-30 14:17 -0700
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 08:31 +1100
      Re: 1 > 0 == True -> False Joshua Landau <joshua@landau.ws> - 2014-01-30 23:36 +0000
        Re: 1 > 0 == True -> False Rotwang <sg552@hotmail.co.uk> - 2014-01-31 00:10 +0000
          Removal of iterable unpacking in function calls (was: 1 > 0 == True -> False) Ben Finney <ben+python@benfinney.id.au> - 2014-01-31 11:21 +1100
            Re: Removal of iterable unpacking in function calls Rotwang <sg552@hotmail.co.uk> - 2014-01-31 00:32 +0000
          Re: 1 > 0 == True -> False Joshua Landau <joshua@landau.ws> - 2014-01-31 00:32 +0000
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 11:01 +1100

csiph-web