代码拉取完成,页面将自动刷新
package main
import "fmt"
func main() {
// 重点1的示例
var srcInt = int16(-255)
// 请注意, 之所以要执行uint16(srcInt), 是因为只有这样才能得到全二进制的表示.
// 例如, fmt.Printf("%b", srcInt)将打印出"-11111111", 后者是负数符号再加上srcInt的绝对值的补码
// 而fmt.Printf("%b", uint16(srcInt))才会打印出srcInt原值的补码"1111111100000001".
fmt.Printf("The complement of srcInt: %b (%b)\n", uint16(srcInt), srcInt)
dstInt := int8(srcInt)
fmt.Printf("The complement of dstInt: %b (%b)\n", uint8(dstInt), dstInt)
fmt.Printf("The value of dstInt: %d\n", dstInt)
fmt.Println()
// 重点2的示例
fmt.Printf("The Replacement Character: %s\n", string(-1))
fmt.Printf("The Unicode codepoint of Replacement Character: %U\n", string(-1))
fmt.Println()
// 重点3的示例
srcStr := "你好"
fmt.Printf("The string: %q\n", srcStr)
fmt.Printf("The hex of %q: %x\n", srcStr, srcStr)
fmt.Printf("The byte slice of %q: %x\n", srcStr, []byte(srcStr))
fmt.Printf("The string: %q\n", string([]byte{'\xe4', '\xbd', '\xa0', '\xe5', '\xa5', '\xbd'}))
fmt.Printf("The rune slice of %q: %U\n", srcStr, []rune(srcStr))
fmt.Printf("The string: %q\n", string([]rune{'\u4F60', '\u597D'}))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。