&^在Go中的含义是什么?

发布于 2025-02-03 03:14:28 字数 207 浏览 3 评论 0原文

在以下代码中,输出为8,因此二进制为1000。

为什么这样?

a := 10
b: = 3

fmt.Println(a &^ b)
fmt.Printf("a &^ b: %b\n", uint64(a &^ b))

这在戈兰。有人告诉我,当零件为0时,它将在1中输出,但这将导致0100,即4。

In the following piece of code, the output is 8 and therefore 1000 in binary.

Why is this the case?

a := 10
b: = 3

fmt.Println(a &^ b)
fmt.Printf("a &^ b: %b\n", uint64(a &^ b))

This is in golang. I have been told it is when the bits are both 0 it will output in 1, but this would result in 0100, which is 4.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文