首页 > 未分类 > long长整数
2017
07-16

long长整数

Name

long长整数

   

Examples

long a; // Declare variable ‘a’ of type long and assign a large value:

//a = 2147483648; // Error: The literal of type int is out of range

a = 2147483648L; // Instead, add an “L” to the number to mark it as a long

 

long b = -256; // Declare variable ‘b’ and assign it the value -256

long c = a + b; // Declare variable ‘c’ and assign it the sum of ‘a’ and ‘b’

int i = (int)c; // Converts the value of ‘c’ from a long to an int

Description

描述

Datatype for large integers. While integers can be as large as 2,147,483,647 and as low as -2,147,483,648 (stored as 32 bits), a long integer has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (stored as 64 bits). Use this datatype when you need a number to have a greater magnitude than can be stored within an int. When assigning literal values that are larger than this magnitude, it is necessary to also append the qualifier “L” to the number, as shown in the example above. Processing functions don’t use this datatype, so while they work in the language, you’ll usually have to convert to a int using the (int) syntax before passing into a function.

长整数的数据类型。虽然整数的大小可以是2147483647和低至-2,147,483,648 (存储为32), 但长整数的最小值为-9,223,372,036,854,775,808, 最大值为 9223372036854775807 (存储为64)。当您需要一个数字比可以存储在 int. 中更大的数量时, 使用此数据类型当指定大于此大小的文本值时, 还必须将限定符 “l” 追加到该数字, 如上面的示例所示。处理函数不使用此数据类型, 因此, 当它们在语言中工作时, 通常必须在传递到函数之前使用 (int) 语法转换为 int

Syntax

语法

long var

long var = value

Parameters

参数

var

variable name referencing the value

value

any integer value

Related

相关

int



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。