Constants for source code, inverse code, and complement and data type

Source: Internet
Author: User

1. In the computer, only 0 and 1. Before processing the data, it must be put into memory for saving. Determines the format in which data is saved, depending on the data type.

Integer in complement form,

Real numbers are in the form of floating-point numbers

The characters are in ASCII format.

2. Each type of data is divided into constants and variables. By class is also divided into:

Base type: integer real character type enum type

Constructed type: Array type struct type union type

Pointer type

Null type (also called No value type): void

3. Conversion of binary and other binary

Rule: Starting from the decimal point, the integer part to the left and the fractional parts to the right.

Octal three bit, 16 binary 4 bit.

Binary operations: +-*/%

4. Use the bits of the computer's word length to indicate the number of machines. Numbers and values.

The number of machines with sign bits corresponds to the value of the machine number. 0 means positive, 1 is negative.

When all bits of a computer's word length are used to represent numeric values, it is called an unsigned number.

5. Original code, anti-code, complement

Anti-code and the complement of the original code to get.

First, note that the inverse code and complement of positive numbers are the same as the original code.

Negative number of the anti-code: is the digital character bit unchanged, that is, 1 is negative, the value of the partial inverse, that is, the opposite number.

The complement of negative numbers: is the number of characters, that is, 1 is negative, the value part of its inverse code plus 1.

The original code of the integer x means: its number character is 0, and 1 is negative. Its numeric part is the binary of the absolute value of x.

The word length is assumed to be 8 bits:

"-1" Original code = 1000,0001

"-1" anti-code =1111,1110

"-1" complement =1111,1111

The digit character bit is always the same.

6. Fixed-point and floating-point numbers

Fixed-point number: called a fixed-point integer when the specified decimal position is fixed at the lowest bit of the machine number.

Floating-point number: Also called real number, its representation is similar to scientific counting method.

-100.011=-10001.1x2^-010 = -0.100011x2^+011 = -0.0100011x2^+100,s is the mantissa and J is the order code.

Specifies that the mantissa of the floating-point number is in pure decimal form in the computer, 0.100011 in the above example, 0.010011 is.

If the mantissa is the highest bit 1, called the normalized number, the 0.100011x2^+011=0.100011*2^11 in the above example is the normalized number

Storage form: Order | order | Number of characters | mantissa

Storage form bit for the above example: 0|11|1|1011

Note: Both the order and the mantissa can be stored in complement.

7. ASCII

Characters include a variety of text, numbers, symbols, and controls. Inside the computer, they are also represented in binary notation.

There are many ways to encode characters, using the most common ASCII (American standard Code for Information Interchange).

8. How many bits of constant and variable occupy memory?

The number of primitive (int) shapes that occupy bytes in memory is related to the compiler.

Turbo c: An int occupies 16bit of memory unit.

VC: 1 int occupies 32 bits of memory unit, which is stored in a complementary fashion.

9. A character constant is an integer. Characters are stored in memory in the form of an ASCII code value.

#include <stdio.h>
Main (void)
{
Char a= ' 0 ';
int b=48;
printf ("%d%c\n", A, b);
}

10. String constants are also called string literals, which are sequences of characters consisting of 0 or more characters enclosed in double quotation marks. "I am a Student" ""

NOTE: Double quotation marks are not part of a string, it is used only with a qualified string.

C language rules: At the end of each string, the system automatically adds a string end marker ' \ \ ' to determine whether the string ends.

The storage form of China: ' C ' | ' H ' | ' I ' | ' N ' | ' A ' | ' + ', so it contains 6 characters.

11. Symbolic constants are a constant represented by an identifier, and C defines a symbolic constant using # define. Symbolic constants are generally denoted by uppercase letters.

#define PI 3.1415926

Constants for source code, inverse code, and complement and data type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.