加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

什么是golang中的^ 0?

发布时间:2020-12-16 19:22:44 所属栏目:大数据 来源:网络整理
导读:我在代码库中看到^ 0. 例: type stat struct { ... min int64 ...}newStat := stat{min: ^0} ^ 0是什么意思? 根据 the docs: ^x bitwise complement is m ^ x with m = “all bits set to 1” for unsigned x and m = -1 for signed x 这意味着^ 0与其他
我在代码库中看到^ 0.

例:

type stat struct {
  ...
  min int64
  ...
}

newStat := stat{min: ^0}

^ 0是什么意思?

根据 the docs:

^x bitwise complement is m ^ x with m = “all bits set to 1” for

unsigned x and m = -1 for signed x

这意味着^ 0与其他主流语言中的?0相同.

在two’s complement(大多数编程语言采用)上,零补码的值为-1(在有符号数据类型上).所以这是一种写作方式:

newStat := stat{min: -1}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读