c浮点型变量初始值整数_C数字变量类型整数,长整型,浮点型

c浮点型变量初始值整数

c浮点型变量初始值整数

[rps-include post=6557]

[rps-include post = 6557]

As we learn variables are used to store values and variables have type. Type provides information about the value hold in the variable. Numeric types used to hold numerical data like 3 , 3.5 , 23.354354646 etc. Numerical types provides simplicity and performance while making mathematical operations. There are 5 different numerical types. Here we go

随着我们的学习,变量用于存储值,并且变量具有类型。 类型提供有关变量中的值保留的信息。 用来保存数值数据的数值类型,例如3,3.5,23.354354646等。数值类型在进行数学运算时提供了简单性和性能。 有5种不同的数字类型。 开始了

整数(Integer)

Integers are normal counting numbers. To specify a variable type as integer we use int before variable name. Integer variables require generally 4 byte memory to hold data. Integer variables can hold values between-2,147,483,648 to 2,147,483,647 . Here is some example about integer.

整数是正常的计数数字。 要将变量类型指定为整数,我们在变量名称前使用int 。 整数变量通常需要4个字节的内存来保存数据。 整数变量的值可以介于-2,147,483,648到2,147,483,647之间。 这是有关整数的一些示例。

int age=25;

Here we have created an integer variable named age which holds value 25

在这里,我们创建了一个名为age的整数变量,该变量的值为25

(Short)

Short type is used variable those will hold lower  numbers versus integer. Short type specifier is same with the type name as short . Short variables require 2 byte to hold in memory. Short number range  is between -32,768 and 32,767 .

短类型用于变量,它们将保留比整数小的数字。 短类型说明符与名称相同。 短变量需要2个字节才能保存在内存中。 短数字范围在-32,768和32,767之间。

short length=180;

We have created a short type variable named length with value 180

我们创建了一个简短的类型变量,名为length ,其值为180

(Long)

Long is used to hold more than integer values long requires 4 byte for memory and holds between -2,147,483,648 to 2,147,483,647 .

Long用于保存多于整数的值,long需要4个字节的内存,并且保存在-2,147,483,648到2,147,483,647之间。

long total=12314235345;

Variable named total holds value 12314235345 which is a long type.

名为total的变量保存值为12314235345,这是一个长类型。

浮动 (Float)

Float variable type is different from above variable types because above types used only counting numbers. If we want to use floating numbers float is the type we will use. Here is some floating number examples 1.0 , 123.345345, 34355.54 etc. Float variables requires 4 byte memory and hold values between 1.2E-38 to 3.4E+38 which is equal 6 decimal places.

浮点变量类型与上面的变量类型不同,因为上面的类型仅使用数字进行计数。 如果我们要使用浮点数,我们将使用float类型。 这是一些浮点数示例1.0,123.345345,34355.54等。浮点变量需要4个字节的内存,并保持1.2E-38到3.4E + 38之间的值,它们等于6个小数位。

float percentage=123.123;

Variable named percentage holds 123.123 which’s type is float.

变量命名比例持有123.123其中的类型为浮动。

LEARN MORE  Python JSON Encoder and Decoder Tutorial with Examples
了解更多带有示例的Python JSON编码器和解码器教程

(Double)

Double is similar to the float type but double have double capacity according to  float. so double variables will use 8 byte memory and will hold values between. 2.3E-308 to 1.7E+308 which is equivalent 15 decimal places.

Double与float类型类似,但double根据float具有两倍的容量。 因此,双精度变量将使用8字节内存,并且将保持两者之间的值。 2.3E-308至1.7E + 308,相当于15个小数位。

double percentage=123.12345345343;

Variable named percentage holds 123.123 which’s type is double.

名为百分比变量持有123.123其中的类型是双。

浮动vs双 (Float vs Double)

Float and double variables types both hold float numbers. Why shouldn’t we use all ways double to make development more easy and less error prone? Because double requires more memory and using all ways double variables will be a bad practice for memory management.

浮点数和双精度变量类型都保存浮点数。 为什么我们不应该使用所有方式加倍以使开发更容易,更不易出错? 因为double需要更多的内存,并且使用所有方式,double变量对于内存管理都是不好的做法。

[rps-include post=6557]

[rps-include post = 6557]

翻译自: https://www.poftut.com/c-numeric-variable-types-integer-long-float/

c浮点型变量初始值整数

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值