A Tour of Go Numeric Constants

Numeric constants are high-precision values.

An untyped constant takes the type needed by its context.

Try printing needInt(Big) too.

package main 

import "fmt"

const (
    Big = 1 << 100
    Small = Big >> 99
)

func needInt(x int) int {
    return x*10 + 1
}

func needFloat(x float64) float64{
    return x * 0.1
}

func main() {
    fmt.Println(needInt(Small))
    fmt.Println(needFloat(Small))
    fmt.Println(needFloat(Big))
}
时间: 2024-10-11 16:55:54

A Tour of Go Numeric Constants的相关文章

A Tour of Go: Basics 1

Packages, variables and functions Packages packages中,以大写字母开头的name是exported name,当import package时,只有exported name可以被从外部访问. Functions 同type的连续参数可以只在最后指明type.函数可以有多个返回值. func swap(x, y string) (string, string) { return y, x } Go支持有name的返回值: 函数定义时就定义好返回变

leetcode Database3

一.Nth Highest Salary Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given the above Employee table, the nth hig

peoplesoft SQR language

Understanding SQR Data Elements !Variables!Variables are storage places for text or numbers that you define and manipulate.!• $ begins a text or date variable.!• # begins a numeric variable.!• % begins a list variable.!• @ begins a variable name for

YASM User Manual

This document is the user manual for the Yasm assembler. It is intended as both an introduction and a general-purpose reference for all Yasm users. 1.?Introduction Yasm is a BSD-licensed assembler that is designed from the ground up to allow for mult

NASM Syntax

NASM has a simplified syntax designed to let the user code with minimum overhead. In its simplest form, a NASM program needs nothing more than the assembly-language instructions; no assembler directives are necessary. NASM also makes some improvement

21/CLASS - C Language Style for Scalability——ZeroMQ官网建议的C语言命令规范

http://rfc.zeromq.org/spec:21 Table of Contents License Change Process Language Goals Quality Aspirations Common Problems General Style Definitions Language Naming Project Style Project Focus Project Name General Layout Dependencies Project Header Fi

JVMS Specification(2)-Compiling for the Java Virtual Machine

Subsections 2       Compiling for the Java Virtual Machine 2.1        Format of Examples 2.2        Use of Constants, Local Variables, and Control Constructs 2.3        Arithmetic 2.4        Accessing the Runtime Constant Pool 2.5        More Control

iOS多版本多设备适配的问题

好吧,能找到这文章的,一般是接到了如下需求:  我是从raywenderlich抽了点内容出来做日记,另外,本文说的不是布局的适配,而是因为ios的升级带来的各版本代码上的不兼容. Deployment Target vs. Base SDK 总的来说,Base SDK表示你愿意支持的最高版本,位于你要设置的Target的属性页的Build Settings > Architectures,一般就选择Latest iOS即可,比如我写这篇日志的时候已经是8.0了 而Deployment Targ

OpenSCAD三维造型设计语言

cube Creates a cube at the origin of the coordinate system. When center is true the cube will be centered on the origin, otherwise it is created in the first octant. The argument names are optional if the arguments are given in the same order as spec