Re: When is min(a, b) != min(b, a)?

2008-02-04 Thread Albert van der Horst
In article [EMAIL PROTECTED], Steven D'Aprano [EMAIL PROTECTED] wrote: On Thu, 24 Jan 2008 13:34:56 +, Antoon Pardon wrote: On 2008-01-21, Steven D'Aprano [EMAIL PROTECTED] wrote: On Sun, 20 Jan 2008 21:15:02 -0600, Albert Hopkins wrote: According to the IEEE-754 standard the usual

Re: When is min(a, b) != min(b, a)?

2008-01-28 Thread Antoon Pardon
On 2008-01-25, Steven D'Aprano [EMAIL PROTECTED] wrote: On Fri, 25 Jan 2008 07:57:13 +, Antoon Pardon wrote: But if you consider that having x is not smaller than y be equivalent to x is greater than or equal to y is more important than forcing a boolean answer in the first place, then

Re: When is min(a, b) != min(b, a)?

2008-01-28 Thread Mark Dickinson
On Jan 28, 6:50 am, Antoon Pardon [EMAIL PROTECTED] wrote: My personal preference would be that python would allow people the choice, with the default being that any operation that resulted in a non numeric result would throw an exception. People who somehow made it clear they know how to

Re: When is min(a, b) != min(b, a)?

2008-01-28 Thread Mark Dickinson
On Jan 28, 6:50 am, Antoon Pardon [EMAIL PROTECTED] wrote: People who somehow made it clear they know how to work with inf, and NaN results, would get silent NaN where no exceptions would be thrown. One other thing: there's an excellent starting point for considering how things should work, in

Re: When is min(a, b) != min(b, a)?

2008-01-25 Thread Pete Forman
Mark Dickinson [EMAIL PROTECTED] writes: Any change to Python that made == and != checks involving NaNs raise an exception would have to consider the consequences for set, dict, list membership testing. and if Python had separate operators for these two purposes it wouldn't be Python

Re: When is min(a, b) != min(b, a)?

2008-01-25 Thread Antoon Pardon
On 2008-01-24, Steven D'Aprano [EMAIL PROTECTED] wrote: On Thu, 24 Jan 2008 13:34:56 +, Antoon Pardon wrote: On 2008-01-21, Steven D'Aprano [EMAIL PROTECTED] wrote: On Sun, 20 Jan 2008 21:15:02 -0600, Albert Hopkins wrote: According to the IEEE-754 standard the usual trichotomy of x is

Re: When is min(a, b) != min(b, a)?

2008-01-25 Thread Marc 'BlackJack' Rintsch
On Fri, 25 Jan 2008 07:57:38 +, Pete Forman wrote: Mark Dickinson [EMAIL PROTECTED] writes: Any change to Python that made == and != checks involving NaNs raise an exception would have to consider the consequences for set, dict, list membership testing. […] and if Python had

Re: When is min(a, b) != min(b, a)?

2008-01-25 Thread Steven D'Aprano
On Fri, 25 Jan 2008 07:57:13 +, Antoon Pardon wrote: But if you consider that having x is not smaller than y be equivalent to x is greater than or equal to y is more important than forcing a boolean answer in the first place, then you need something to signal Undefined, and an exception

Re: When is min(a, b) != min(b, a)?

2008-01-25 Thread Robert Kern
Marc 'BlackJack' Rintsch wrote: On Fri, 25 Jan 2008 07:57:38 +, Pete Forman wrote: Mark Dickinson [EMAIL PROTECTED] writes: Any change to Python that made == and != checks involving NaNs raise an exception would have to consider the consequences for set, dict, list membership

Re: When is min(a, b) != min(b, a)?

2008-01-24 Thread Antoon Pardon
On 2008-01-21, Steven D'Aprano [EMAIL PROTECTED] wrote: On Sun, 20 Jan 2008 21:15:02 -0600, Albert Hopkins wrote: According to the IEEE-754 standard the usual trichotomy of x is less than y, x is equal to y, or x is greater than y has to be extended to include x and y are unordered.

Re: When is min(a, b) != min(b, a)?

2008-01-24 Thread Christian Heimes
Antoon Pardon wrote: That doesn't follow. The problem is not that x nan returns False because that is correct since x isn't smaller than nan. The problem is cmp(x, nan) returning 1, because that indicates that x is greater than nan and that isn't true. Please report the problem. cmp(),

Re: When is min(a, b) != min(b, a)?

2008-01-24 Thread Paddy
On Jan 24, 2:28 pm, Christian Heimes [EMAIL PROTECTED] wrote: Antoon Pardon wrote: That doesn't follow. The problem is not that x nan returns False because that is correct since x isn't smaller than nan. The problem is cmp(x, nan) returning 1, because that indicates that x is greater

Re: When is min(a, b) != min(b, a)?

2008-01-24 Thread Pete Forman
Christian Heimes [EMAIL PROTECTED] writes: Antoon Pardon wrote: That doesn't follow. The problem is not that x nan returns False because that is correct since x isn't smaller than nan. The problem is cmp(x, nan) returning 1, because that indicates that x is greater than nan and that isn't

Re: When is min(a, b) != min(b, a)?

2008-01-24 Thread Steven D'Aprano
On Thu, 24 Jan 2008 13:34:56 +, Antoon Pardon wrote: On 2008-01-21, Steven D'Aprano [EMAIL PROTECTED] wrote: On Sun, 20 Jan 2008 21:15:02 -0600, Albert Hopkins wrote: According to the IEEE-754 standard the usual trichotomy of x is less than y, x is equal to y, or x is greater than y has

Re: When is min(a, b) != min(b, a)?

2008-01-24 Thread Steven D'Aprano
On Thu, 24 Jan 2008 16:51:16 +, Pete Forman wrote: Christian Heimes [EMAIL PROTECTED] writes: Antoon Pardon wrote: That doesn't follow. The problem is not that x nan returns False because that is correct since x isn't smaller than nan. The problem is cmp(x, nan) returning 1, because

Re: When is min(a, b) != min(b, a)?

2008-01-24 Thread Mark Dickinson
On Jan 24, 7:09 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: I'm having a lot of trouble finding the canonical IEEE-754 standard, so I'm forced to judge by implementations and third party accounts. For example, this is what IBM says: There's a recent draft of IEEE 754r (the

math and numerical fixes (was: When is min(a, b) != min(b, a)?)

2008-01-23 Thread Christian Heimes
Jason wrote: Please note that NaN's are very funky and platform dependent. They depend on their underlying platform's C library for creation and display. On windows, float('nan') will cause an exception, as there are no valid string representations of NAN that can be converted to the

Re: When is min(a, b) != min(b, a)?

2008-01-23 Thread Christian Heimes
Grant Edwards wrote: In many applications (e.g. process control) propogating NaN values are way too useful to avoid. Avoiding NaN would make a lot of code far more complicated than would using them. NaNs are very useful for experienced power users but they are very confusing for newbies or

Re: When is min(a, b) != min(b, a)?

2008-01-23 Thread Russell E. Owen
In article [EMAIL PROTECTED], Christian Heimes [EMAIL PROTECTED] wrote: Grant Edwards wrote: In many applications (e.g. process control) propogating NaN values are way too useful to avoid. Avoiding NaN would make a lot of code far more complicated than would using them. NaNs are very

Re: When is min(a, b) != min(b, a)?

2008-01-23 Thread Robert Kern
Russell E. Owen wrote: In article [EMAIL PROTECTED], Christian Heimes [EMAIL PROTECTED] wrote: Grant Edwards wrote: In many applications (e.g. process control) propogating NaN values are way too useful to avoid. Avoiding NaN would make a lot of code far more complicated than would using

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Steven D'Aprano
On Sun, 20 Jan 2008 21:15:02 -0600, Albert Hopkins wrote: This issue may have been referred to in news:[EMAIL PROTECTED] but I didn't entirely understand the explanation. Basically I have this: a = float(6) b = float('nan') min(a, b) 6.0 min(b, a) nan

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Jason
On Jan 21, 12:00 am, Albert Hopkins [EMAIL PROTECTED] wrote: On Sun, 20 Jan 2008 20:16:18 -0800, Paddy wrote: I am definitely NOT a floating point expert, but I did find this: http://en.wikipedia.org/wiki/IEEE_754r#min_and_max P.S. What platform /Compiler are you using for Python? Linux

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Mark Dickinson
On Jan 21, 9:55 am, Jason [EMAIL PROTECTED] wrote: display.  On windows, float('nan') will cause an exception, as there are no valid string representations of NAN that can be converted to the special floating point value.  Also, if you manage to create a nan under Windows, it displays as

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Grant Edwards
On 2008-01-21, Albert Hopkins [EMAIL PROTECTED] wrote: This issue may have been referred to in news:[EMAIL PROTECTED] but I didn't entirely understand the explanation. Basically I have this: a = float(6) b = float('nan') min(a, b) 6.0 min(b, a) nan

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Grant Edwards
On 2008-01-21, Jason [EMAIL PROTECTED] wrote: Infinite values are also problematic. In almost all cases, it is far better to avoid infinite and NaN values. In many applications (e.g. process control) propogating NaN values are way too useful to avoid. Avoiding NaN would make a lot of code

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Pete Forman
Grant Edwards [EMAIL PROTECTED] writes: For applications I work on, it should be NaN. But I think the result of comparing a Normal to a NaN is undefined, so the above behavior is allowed by the IEEE spec. Comparison of two floating point datums results in exactly one of these being true:

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Steven D'Aprano
On Mon, 21 Jan 2008 18:00:05 +, Pete Forman wrote: If NaNs in your data are important then you must take care in explicit and implicit comparisons to consider unordered results. And even if they're not important, beware of bugs from failing to consider unordered results due to unexpected

When is min(a, b) != min(b, a)?

2008-01-20 Thread Albert Hopkins
This issue may have been referred to in news:[EMAIL PROTECTED] but I didn't entirely understand the explanation. Basically I have this: a = float(6) b = float('nan') min(a, b) 6.0 min(b, a) nan max(a, b) 6.0 max(b, a) nan Before I did not know

Re: When is min(a, b) != min(b, a)?

2008-01-20 Thread Bonjour
'NaN' means Not a number. according to Python semantics, if you try to compare it with any other float numbers, it should return FALSE. just like 1.0 'abc' False Since it always return FALSE, it is not a surprise for your question. If you wish to get infinitive number, you'd use 'inf' or

Re: When is min(a, b) != min(b, a)?

2008-01-20 Thread Bonjour
'NaN' means Not a number. according to Python semantics, if you try to compare it with any other float numbers, it should return FALSE. just like: 1.0 'abc' False Since it always return FALSE, it is not a surprise for your question. If you wish to get infinitive number, you'd use

Re: When is min(a, b) != min(b, a)?

2008-01-20 Thread Paddy
On Jan 21, 3:15 am, Albert Hopkins [EMAIL PROTECTED] wrote: This issue may have been referred to in news:[EMAIL PROTECTED] but I didn't entirely understand the explanation. Basically I have this: a = float(6) b = float('nan') min(a, b) 6.0 min(b, a) nan

Re: When is min(a, b) != min(b, a)?

2008-01-20 Thread Albert Hopkins
On Sun, 20 Jan 2008 20:16:18 -0800, Paddy wrote: I am definitely NOT a floating point expert, but I did find this: http://en.wikipedia.org/wiki/IEEE_754r#min_and_max P.S. What platform /Compiler are you using for Python? Linux with GCC 4 -a --