On Tuesday, 27 April 2021 at 07:28:39 UTC+1 christoph...@gmail.com wrote: > It seam that C is wrong on this one and Go is right. The rationale is that > a NaN must propagate through operations so that we can detect problems > (avoid silent NaNs). See https://en.wikipedia.org/wiki/NaN > > Thus any operation involving a NaN must return an NaN and this includes > Max and Min. > >
That Wikiepedia page has a paragraph about this specific case: *In section 6.2 of the old IEEE 754-2008 <https://en.wikipedia.org/wiki/IEEE_754-2008_revision> standard, there are two anomalous functions (the maxNum and minNum functions, which return the maximum of two operands that are expected to be numbers) that favor numbers — if just one of the operands is a NaN then the value of the other operand is returned. The IEEE 754-2019 <https://en.wikipedia.org/wiki/IEEE_754-2019_revision> revision has replaced these functions as they are not associative <https://en.wikipedia.org/wiki/Associative_property> (when a signaling NaN appears in an operand).[4] <https://en.wikipedia.org/wiki/NaN#cite_note-4>[5] <https://en.wikipedia.org/wiki/NaN#cite_note-5>* Reference [4] is: David H.C. Chen (21 February 2017). "The Removal/Demotion of MinNum and MaxNum Operations from IEEE 754™-2018" <http://754r.ucbtest.org/background/minNum_maxNum_Removal_Demotion_v3.pdf> (PDF). It very clearly describes the problem and gives the behaviours of some selected implementations. Given that this was only fixed in 2019, you can hardly blame C for getting it wrong :-) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/9879b8f5-2ac4-4f26-b7d4-f62177730e28n%40googlegroups.com.