Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Real variables in C language are divided into two types, they are () and ()
Real variables in C language are divided into two types, they are () and ()

Real type variables in C language are divided into two types, they are () and ()

float and double real type variables

Real type Variables are divided into two categories: single-precision type and double-precision type. The type specifiers are float single-precision specifier and double double-precision specifier. In Turbo C, the single precision type occupies 4 bytes (32 bits) of memory space, its value range is 3.4E-38~3.4E+38, and can only provide seven significant digits. The double precision type occupies 8 bytes (64 bits) of memory space, its value range is 1.7E-308~1.7E+308, and can provide 16 significant digits.

The format and writing rules of real type variable description are the same as those of integer type.

For example: float x,y; (x,y are single-precision real quantities)

double a,b,c; (a,b,c are double-precision real quantities) Quantity)

Real type constants are treated as double precision, regardless of single or double precision.

void main(){

float a;

double b;

a=33333.33333;

b=33333.33333333333333;

printf("%f\n%f\n",a,b);

} In C language, real variables are divided into two types , they are_______________.

Float type and double type. What are the two types of real variables in the C language?

Float and double Real variables in C language are divided into float type and double type, which are stored as floating point numbers and divided into number symbols, _______ and _______ parts

Real-type variables in C language are divided into float type and double type. They are stored as floating point numbers and are divided into number symbols, exponents and mantissas. Real-type variables in C language are divided into float type and double type. According to Floating point numbers are stored and divided into several parts: number sign, _______ and mantissa.

Code. It is used to indicate the position of the decimal point in the number. It is a signed integer.

Are real variables in C language positive or negative?

Real type variable!!!!!!

What is a real type variable? And the ASCII code is moved out? There are only characters and single characters are encoded using ASCII." Means "

The double float type is not only signed, but they are even defined as unsigned double and unsigned float, which are wrong! The compiler will not report an error, but the output will definitely make you feel puzzling! The difference between double-precision real variables and long double-precision real variables in C language

Double-precision real variables and long double-precision real variables: This is not always a difference.

The precision of long double is not lower than double.

In early VC, long double was an alias for double.

In modern X86 compilers, double is generally a 64-bit floating point number, and long double is generally an 80-bit floating point number.

For other platforms, double and long double have different interpretations. Generally, it is necessary to use something like sizeof to determine the meaning of long double in the system where it is located.

In the 80x86 system, 80x87 itself is an 80-bit floating point coprocessor, so generally long double corresponds to 80-bit floating point numbers, but there are a few systems that use 128-bit floating point numbers or 64-bit floating point numbers. Floating point number. Double is generally a 64-bit floating point number, which is obtained by 80x87 truncation. Although it is an 80-bit floating point number, it may occupy 10, 12 or 16 bytes of storage space, which varies with the compiler.

There is no wealth value, it is just a desire to learn. I hope China can enjoy the resources - "The spirit of sharing should be that you have to accumulate wealth

Generally we The sexual enjoyment mentioned is in both directions.

The one-way spirit is not the most enjoyable one.

Why do integer variables output 0 as real variables in C language?

1. The storage format and layout of integer and floating-point numbers in memory are different (to understand the memory layout and representation of floating-point numbers, please refer to: blog.csdn./songjinshi/article/details/7753777 )

2. When printf pushes parameters onto the stack, it pushes parameters according to the type of the actual parameters, rather than according to the type specified in the formatting character. The specific pushing process is as follows. Therefore, the type of the actual parameters pushed onto the stack does not match the type used by the actual function (the key is that the size of the memory occupied is different), so the result as mentioned in the title will appear in the specific analysis, because the memory layout of the integer is being parsed It will be very small when it is a floating point number, because the integer is originally stored in 4 bytes and is parsed as an 8-byte floating point number, so the resulting value will be very small, just like the representation of floating point numbers: denormalization: when When all the binary bits of E are 0, N is a denormalized form.

Note that the implicit bit to the left of the decimal point is 0 at this time. Why e is equal to (1-bias) instead of (-bias)? This is mainly designed for the smooth transition between normalized values ??and non-normalized values. We will continue to discuss this later.

With the denormalized form, we can represent 0. After setting the sign bit S to 1 and setting all other bits to 0, we get -0.0; similarly, setting all bits to 0 will get +0.0. Denormalized numbers also have other uses, such as representing decimals that are very close to 0, and these decimals are evenly close to 0, which is called the "gradually underflow" property.

Posted below are two pieces of disassembly code to analyze how parameters are pushed onto the stack:

printf("%f",45);

00405028 mov esi, esp

0040502A push 2Dh

0040502C push offset _ORDER_SERVER_ADDRESS-0ACh (43F2ACh)

00405031 call dword ptr [__imp__printf (43C124h)]

00405037 add esp,8

printf("%f",d); (d is an integer variable)

00405028 mov esi,esp

0040502A mov ecx,dword ptr [d]

0040502D push ecx

0040502E push offset _ORDER_SERVER_ADDRESS-0ACh (43F2ACh)

00405033 call dword ptr [__imp__printf (43C124h)]

00405039 add esp,8

0040503C cmp esi,esp

0040503E call _RTC_CheckEsp (439760h)

double a=5,c ;

float b;

int d=0x40a00000,y=6;

int *p;

char s=5;

p=&d;

b=(float)a;

printf("%f,%f,%f,%f,%f, %f,%d",b,c,(float)d,s,(float)s,y,y);

00405028 mov esi,esp

0040502A mov ecx ,dword ptr [y]

0040502D push ecx

0040502E mov edx,dword ptr [y]

00405031 push edx

00405032 movsx eax,byte ptr [s]

00405036 mov dword ptr [ebp-34h],eax

00405039 fild dword ptr [ebp-34h]

0040503C sub esp,8

0040503F fstp qword ptr [esp]

00405042 movsx ecx,byte ptr [s]

00405046 push ecx

00405047 fild dword ptr [d]

0040504A sub esp,8

0040504D fstp qword ptr [esp]

00405050 sub esp,8

00405053 fld qword ptr [c]

00405056 fstp qword ptr [esp]

00405059 fld dword ptr [b]

0040505C sub esp,8

0040505F fstp qword ptr [esp]

00405062 push offset _ORDER_SERVER_ADDRESS-0C4h (43F2ACh)

00405067 call dword ptr [__imp__printf (43C124h)]

0040506D add esp,30h

00405070 cmp esi,esp

00405072 call _RTC_CheckEsp (439780h) What are the two types of real variables in C language

Single precision float

Double precision double How many types of variables are there in the C language?

The basic types are:

int

short

char

float

double

long

unsigned

pointer

There are also combined data types such as arrays, structures, and unions, in addition to Data types can be customized.