On Wed, Jul 8, 2020 at 10:09 AM 'simon place' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> summary:
>
> converting to int from NaN results in arch dependent values.
> ...
>
i see that NaN isn't really defined as an int, so any returned value isn't
> 'incorrect', but shouldn't the value returned be consistent across
> architectures? these end-of-range values play fine with my algorithm but 0
> doesn't.
>
> i've fixed by special-casing NaN values. (may end up using a build flag.)
>

The result of what you're doing is undefined. You might as well be
executing the HCF instruction. See
https://stackoverflow.com/questions/10366485/problems-casting-nan-floats-to-int
for
one reasonably good discussion. You absolutely have to special-case NaN if
it can be an input to your code. You should not assume it will be converted
to a particular int value.

-- 
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_wLW7F%3DF_BiUgdTLTGF_7uMsWp%2B%2BH03bYFGgY5NVa9%2Bg%40mail.gmail.com.

Reply via email to