On Wed, Jul 8, 2020 at 3:26 PM 'simon place' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> i remember wondering, a while ago, why it was that NaN etc. weren't
> constants, after-all their encoding is unique and can't vary.
>
> seems the reason for this is.....
>
> "Numeric constants represent exact values of arbitrary precision and do
> not overflow. Consequently, there are no constants denoting the IEEE-754
> negative zero, infinity, and not-a-number values."
>
> not sure how negative zero, for example, fails here, its a value of a
> float type, so it is Numeric, an exact value, and i don't really see how
> "of arbitrary precision and do not overflow" apply?
>

If you're on a system with twos-complement representation for ints, rather
than ones-complement or sign-and-magnitude, you can't represent negative
zero in an int type. How would you convert float64(-0) to an int without
losing information? It isn't overflow in the usual sense but the point is
that those values cannot be represented by any of the int data types.

but this is stymieing the whole point of the way i was doing it,
> simple/clear/short/std.lib leveraging,  because it seems you HAVE to check
> them all, (NaN/+Inf/-Inf/-0) because an "implementation-dependent" value
> could be anything and so potentially exactly what you were expecting right
> up until it isn't!
>

The way you were doing it relies on implementation dependent behavior.
Which is risky even if you never intend to support anything but a single
architecture (e.g., x86_64) and should have a prominent "HERE BE DRAGONS"
comment in the code.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD-1bY-nezMOzE0deg6dY06OS_Yc-xR%3DFdrss49HV0tM5w%40mail.gmail.com.

Reply via email to