Hacker News new | ask | show | jobs
by steveklabnik 3089 days ago
> All of them evaluate to Infinity when dividing a double by 0.0. No exceptions to be found.

Well, Rust doesn't have exceptions, so it wouldn't happen, but yeah. To your parent, these languages follow IEEE 754, as far as I know, which specifies this behavior.

1 comments

Go throws an exception with 1.0/0.0. Unless you specify the type as float64.

Ok overall I'm wrong.

But either way poor design from a usability standpoint and from a consistency standpoint because ints don't do this.

Yeah, floats and ints are just fundamentally different, especially when you're at the level of caring about how hardware deals with things.

TIL about Go:

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.

https://golang.org/ref/spec

Yeah that's one of those things that I learn, and then forget, and then relearn, and forget...

Would probably retain it better if I used Go as my primary language for a year or two.