3 ms·
The variable "p" is a rune. Although the rune type can have negative values, p will only have values >= 0 in this code.
by BarkMore 15y ago
The variable "p" is a rune. Although the rune type can have negative values, p will only have values >= 0 in this code.
- comex 15y agoHow so? If the character is any value less than '0' (say, '!'), p will be set to a negative value.
- BarkMore 15y ago'0' has the decimal value 48, not zero. '!' has the decimal value 33. Here's a demo program that you can run from your browser: http://play.golang.org/p/qAKG9j5E4V http://play.golang.org/p/qAKG9j5E4V All characters have values greater than or equal to zero.
- Dylan16807 15y agocomex said less than '0'. 33 minus 48 is negative.