You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
d := time.Duration(1024)
fmt.Printf("decimal: %d; hex %x\n", d, d)
prints:
decimal: 1024; hex 312e3032347573
not the expected hex 400.
i think that fmt should probably print integer
values as integers if used with integer-specific
format specifiers.
The text was updated successfully, but these errors were encountered:
This is a tough one but I'm inclined to leave things alone. 'x' is an integer format but
it's also a string format and the code says: "If a string is acceptable according to the
format, see if the value satisfies [error or Stringer]".
If 'x' becomes integer in this context, then I need to think about other non-string
formats like %g, and I think it just gets more complicated. Also, making the change
could possibly break code that wants to hexify the String result, which is reasonable
itself.
In short, I will mark this WorkingAsIntended because, although the proposal is
reasonable, so is the existing behavior. To get the behavior you ask for, it's easy and
arguably clearer to convert:
fmt.Printf("decimal: %d; hex %x\n", int(d), int(d))
The text was updated successfully, but these errors were encountered: