29 Feb 2024 |

shu | okay, so the precedent is that several functions already decided that NaN should have lower precedence than Infinity because Infinity is thought of as just another "non-NaN"? | 22:15:52 |

shu | that doesn't give me insight on why they made this decision when the precedence in user `+` is the opposite | 22:16:18 |

TabAtkins | No, the (mixed!) precedent is that, in several functions, if the NaN argument *doesn't affect the result* (aka you could replace it with *any non-NaN* value, and every possible substitution would have no effect on the return value), then the function just returns that consistent value. | 22:18:16 |

TabAtkins | It's not a "lower precedence" thing, it's a "the return value doesn't depend on this argument, so we won't pay any attention to it" thing. | 22:18:49 |

TabAtkins | Infinity *is* just another number; NaN is the weird one that (among other reasons) is returned when multiple possible values are possible. | 22:19:36 |

TabAtkins | `+` is consistent with this behavior: in `Infinity + X` , if X=-Infinity you get NaN, while any other value yields Infinity, so the X's value *is* important to the result, so `Infinity + NaN` has to be NaN too. | 22:23:16 |

shu | Infinity + NaN is NaN, right | 22:30:45 |

shu | but hypot(Infinity, NaN) is Infinity? | 22:30:53 |

shu | that's the inconsistency, no? | 22:31:04 |

TabAtkins | No, substitute *any* non-NaN value for the second argument there. You'll always get Infinity, still. | 22:34:50 |

TabAtkins | So the NaN argument is powerless, and can be safely ignored. | 22:35:06 |

TabAtkins | (`hypot(Infinity, Infinity)` , `hypot(Infinity, 0)` , `hypot(Infinity, -Infinity)` all give `Infinity` ; once one argument is infinite the entire function is guaranteed to return `Infinity` regardless of the other values.) | 22:36:21 |

shu | i think we're talking past each other somehow | 22:36:41 |

TabAtkins | We must be, since you still seem to be talking about this in terms of "precedence", like the existence of an Infinity vs a NaN does something and we have to define which one "wins" when they both appear. | 22:37:19 |

TabAtkins | What I'm explaining is that the behavior isn't about that at all. | 22:37:34 |

shu | looking at just +, `Infinity + NaN` , one cannot know whether the rule that applies is "Infinity is infectious" or "NaN is infectious", and people just internalize it as "NaN is infectious" applies over "Infinity is infectious" | 22:38:00 |

shu | in that Infinity + NaN is a degenerate form that has no intuition in extended real arithmetic | 22:38:18 |

TabAtkins | Sure. But "`Infinity + NaN` yields `NaN` " is *also* consistent with the reasoning I gave, which appears to be the reasoning used by `hypot()` . | 22:38:51 |

TabAtkins | (But not the reasoning used by `min()` /`max()` ; they both use "`NaN` is infectious" logic.) | 22:39:08 |

shu | look at `hypot(Infinity, NaN)` , one also cannot know whether the rule that applies is "Infinity is infectious" or "NaN is infectious", and people just internalize one, except it's confusing now because they need to internalize the other one | 22:39:11 |

TabAtkins | yeah, the logic isn't about infection in hypot() | 22:39:34 |

TabAtkins | is what i keep saying | 22:39:38 |

shu | okay, think i finally see where you're coming from | 22:39:50 |

shu | but doesn't that kick the can one level up? there's still inconsistent in which logic is used for which operations/functions, and it's confusing | 22:40:12 |

TabAtkins | Yes, it's inconsistent no matter *what* reasoning you use | 22:40:24 |

TabAtkins | our functions are just straight up inconsistent in their NaN handling | 22:40:33 |

shu | okay, bear with me, but now we're back at my still not having any insight on how we arrived at this inconsistency in logic | 22:41:09 |

shu | i guess just accident of how things were argued at the time | 22:41:14 |

TabAtkins | yup | 22:48:00 |

1 Mar 2024 |

| ryzokuken (back monday) changed their display name from ryzokuken to ryzokuken (back monday). | 12:28:19 |