Go: integer overflows

王林
Release: 2024-09-10 18:30:32
Original
357 people have browsed it

Go: integer overflows

Let's continue my articles about integer overflows in Go.

Here are examples

var a int var b uint8 a = 255 + 1 b = uint8(a) fmt.Println(b) // 0 conversion overflow a = -1 b = uint8(a) fmt.Println(b) // 255 conversion overflow c, d := 255, 300 res := int8(max(c, d)) fmt.Println(res) // 44 str := "\x99" // hexadecimal representation of Trademark ASCII character: ™ fmt.Println(str[0]) // 153 fmt.Println(int8(str[0])) // -103
Copy after login

Go Playground

The above is the detailed content of Go: integer overflows. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!