上海浦东吸血鬼事件:C语言中的整形常量和实行常量有什么区别?

来源:百度文库 编辑:神马品牌网 时间:2024/05/01 06:48:41

常量,就是固定不变的量,是和变量相对而言的!

整形常量就相当于咱们常说的整数!

实形常量,就相当于常说的小数!在C语言中,实形常小数点后默认是6位。比如:2.500000 不够6位的用0补齐。

这样回答可以吗?

希望你C语言学习进步!

整型常量就是整数常量,实型常量又叫浮点型常量,它们在内存中占用的字节数不同,实型常量能够表达的范围较大,另外实型常量可表示小数,有两种书写形式,一种是我们常用的定点数形式,如:1.234;一种是指数形式,又叫科学表示法,它是在定点数形式后加E(或e)和整数来表示,如:1.234E3表示1234。

整型int,实型float
一个整数,一个含小数

简单地说,整形常量就是整数,实形常量就是实数(整数与小数)!

The Integer
An integer is a number with no fractional part. In C, an integer is never written with a decimal point. Examples are 2, –23, and 2456. Numbers such as 3.14, 0.22, and 2.000 are not integers. Integers are stored as binary numbers. The integer 7, for example, is written 111 in binary. Therefore, to store this number in an 8-bit byte, just set the first 5 bits to 0 and the last 3 bits to 1

The Floating-Point Number
A floating-point number more or less corresponds to what mathematicians call a real number. Real numbers include the numbers between the integers. Some floating-point numbers are 2.75, 3.16E7, 7.00, and 2e–8. Notice that adding a decimal point makes a value a floating-point value. So 7 is an integer type but 7.00 is a floating-point type. Obviously, there is more than one way to write a floating-point number. In brief, the notation 3.16E7 means to multiply 3.16 by 10 to the 7th power; that is, by 1 followed by 7 zeros. The 7 would be termed the exponent of 10.