我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Golang中的^ 0是什么?

I am seeing ^0 in the code base.

Example:

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

newStat := stat{min: ^0}

What does ^0 mean?

According to the docs:

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

unsigned x and m = -1 for signed x

It means that ^0 is the same as ~0 in other mainstream languages.

On a two's complement (which most of the programming languages adopt) the value of the complement of zero is -1 (on an signed data type). So this is a way to write:

newStat := stat{min: -1}

近期文章

  • C ++中的golang样式的“延迟” [重复]
  • golang测试临时目录
  • 设置切片的容量有什么意义?
  • 使用mgo和mongodb的I / O超时
  • 取消引用结构是否会返回新的结构副本?
  • 如何在Go测试输出中确定行号?
  • 如何在Go中支持Allman样式编码?
  • 如何使用goLang执行SQL文件
  • Golang将类型[N] byte转换为[] byte [重复]
  • 使用AES-CFB时Go和Pycrypto的结果不同
  • 在并发应用程序中使用HTTP客户端的最佳方法
  • 如何使fmt.Scanln()读入整数切片
  • 为什么在if语句中创建结构在Go中是非法的?
  • Golang Profiler找不到源代码
  • 获取结构字段类型的简单字符串表示形式
  • Google Go for Java平台?
  • 如何在Golang构建中使用-ldflags -X设置软件包变量
  • go build一直抱怨:go.mod具有post-v0模块路径
  • 如何在杜松子酒中记录响应正文
  • 如何使用Go编程语言为数组分配内存?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华