go vet on playground emits message on printf %x with floating point

59 views
Skip to first unread message

bup...@gmail.com

unread,
Mar 3, 2020, 7:10:00 PM3/3/20
to golang-nuts

Source code:

package main
   
import (
 "fmt"
)
   
func main() {
 fmt.Printf("%x\n", 5.0/7.0)
}


Expected: No message emits by go vet


Actual: go vet emits the following message:

./prog.go:8:2: Printf format %x has arg 5.0 / 7.0 of wrong type float64


According to https://golang.org/pkg/fmt/ , %x with floating point displays hexadecimal notation (with decimal power of two exponent), which is legal usage.

Jake Montgomery

unread,
Mar 4, 2020, 12:07:45 PM3/4/20
to golang-nuts

I'm curious what you use hex float for?
Reply all
Reply to author
Forward
0 new messages