Help us understand the problem. What is going on with this article?

Go by Example: Constants

More than 5 years have passed since last update.

(この記事は Go by Example: Constants を翻訳したものです。)

Goはcharacter, string, booleanと数学的値の定数をサポートしている。

package main

import "fmt"

import "math"

// 定数は constで宣言される。
const s string = "constant"

func main() {
    fmt.Println(s)

    // 定数宣言はvarでの宣言のようにどこでも現れる事ができる。
    const n = 500000000

    // 定数宣言は任意精度演算を行うことができる。
    const d = 3e20 / n
    fmt.Println(d)

    // 数の定数は明示的なキャストなどがされるまでは型が決まっていない。
    fmt.Println(int64(d))

    // 変数の代入や、関数の呼び出しよのうなコンテキストを使うことによって方が与えられる。
    // math.Sin はfloat64を引数をして取る。
    fmt.Println(math.Sin(n))
}

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした