dongmai6666
2015-10-14 16:37
浏览 632
已采纳

在golang中将字符串转换为数字

Golang has strconv library that converts string to int64 and uint64.

However, the rest of integer data types seems to be unsupported as I can't find conversion functions for byte, int16, uint16, int32, uint32 data types.

One can always convert from byte, 16-bit and 32-bit data types to int64 and uint64 without loss of precision. Is that what's intended by language?

图片转代码服务由CSDN问答提供 功能建议

Golang具有 strconv 库,可将字符串转换为int64和uint64。

但是,由于我找不到字节的转换函数,其余的整数数据类型似乎不受支持 ,int16,uint16,int32,uint32数据类型。

始终可以将字节,16位和32位数据类型转换为int64和uint64,而不会损失精度。 那是语言的意图吗?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新