Chinaunix首页 | 论坛 | 博客
  • 博客访问: 32234
  • 博文数量: 11
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 100
  • 用 户 组: 普通用户
  • 注册时间: 2014-10-19 21:19
文章分类
文章存档

2015年(2)

2014年(9)

我的朋友

分类: 敏捷开发

2014-11-24 21:19:49


点击(此处)折叠或打开

  1. // Constants
  2. package main

  3. import "math"
  4. import "fmt"

  5. //const declares a constant value.
  6. const s string = "constant"

  7. func main() {
  8.     fmt.Println(s)
  9.     //A const statement can appear anywhere a var statement can.
  10.     const n = 500000000
  11.     //Constant expressions perform arithmetic with arbitrary precision.
  12.     const d = 3e20 / n
  13.     fmt.Println(d)
  14.     //A numeric constant has no type until it’s given one, such as by an explicit cast.
  15.     fmt.Println(int64(d))
  16.     //A number can be given a type by using it in a context that requires one,
  17.     //such as a variable assignment or function call.
  18.     //For example, here math.Sin expects a float64.
  19.     fmt.Println(math.Sin(n))
  20. }

转自
阅读(824) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~