Not beautiful, but...
https://play.golang.org/p/WWEEJN8LcF
func main() {
i32 := math.Float32frombits(0x7F800000)
fmt.Printf("%T = %v", i32, i32)
}
// float32 = +Inf
On Sat, Sep 10, 2016 at 6:55 PM, <[email protected]> wrote:
> ok I want to assign +Inf as a float32.
>
> Currently I work around like this :
>
> package main
>
> import (
> "fmt"
> )
>
> func main() {
> var a,b,c float32
> a=1
> b=0
> //c=float32(1.0)/float32(0.0) //can't do it
> //c=+Inf //doesn't work - not a keyword
> c=a/b //kludge
> fmt.Println (a,b,c)
> }
>
>
> Couldn't find a way to do this - not even in the math package .. (I see
> that +Inf is in the math package but it is not exported) ie lines 8-10 in
> math/bits.go
>
> Am I missing something obvious.?
>
> In https://golang.org/ref/spec#Numeric_types it states "*float32 the
> set of all IEEE-754 32-bit floating-point numbers" *
>
> If not is a request that +Inf etc be exported from math reasonable ?
> (also signed zeros etc)
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.