On Sun, Sep 11, 2016 at 11:40 AM,  <xiiop...@gmail.com> wrote:
> https://play.golang.org/p/tLSyUw1Ojq
>
> This operation is caught by the compiler
>
> a:=float32(1) / float32(0)
>
>
> ok This has been asked before - but not with a satisfactory answer afaict
>
> The spec says (  https://golang.org/ref/spec#Arithmetic_operators )   The
> result of a floating-point or complex division by zero is not specified
> beyond the IEEE-754 standard; ..
>
> But the IEEE754 standard does specify behaviour, and the divide by zero has
> a valid, defined result.
>
> I get the compiler is trying to catch some sort of error here - but I'm not
> convinced it's ever helpful, and contradicts fully supporting the standard.
>
> Does anyone have a good defence of this compiler warning for floats?

Personally I think it was probably a mistake.

The relevant part of the spec is
https://golang.org/ref/spec#Constant_expressions where it says "The
divisor of a constant division or remainder operation must not be
zero."

Ian

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to