Golang Programming Basics-Preparing a piece

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Golang is Google released open-source programming language, here do not introduce too much, there are many articles on the internet has been introduced to its predecessor is very clear, interested can go to consult, a few days ago, just began to contact the development of Golang, today to take time to do some of the development of the finishing, What we're going to say today is the basic data type of Golang.

Simply introduce the data type, there is no meaning, just a few types, understand what meaning, but a language to set so some data types must have its reasons. We need to look at the different types of data in memory form.

Let's start with a few concepts, bit (bit), Byte (byte), Word (word), three concepts and their relationships.

The computer is the integration of many circuits, in the computer each closed circuit only 0, 12 kinds of states. So the data in the computer is in binary (only 0 and 1) Form the existence. So the essence of computer is the operation of 0,1. bit is the smallest unit of information, which means a bit of information. 0 or 1 means 1bit, so 0000 is 4 bit. The corresponding byte-to-bit relationship exists between 1byte = 8bit, while Word is related to the system hardware (bus, CPU instruction word bits, etc.), such as the data bus is 16 bits, then 1word=2byte, if 32 bits have 1word=4byte. Storage capacity is typically expressed in bytes and is hardware-independent, 1byte=8bit. In the computer also involves a concept is the number of CPU bits, that is, the computer CPU can process the bit number of bits, such as the common 32-bit and 64-bit, corresponding to 32bit and 64bit, that is 4byte or 8byte.

We also need to look at the relationship between characters and bytes. This will involve coding problems. Common encodings are ASCII encoded, UTF-8 encoded, Unicode encoded, and the relationship between bytes and characters in different encoding modes is described as follows:
ASCII: An English letter (not case) occupies a byte of space, a Chinese character occupies two bytes of space. A binary number sequence, which is used as a digital unit in a computer, typically a 8-bit binary number, converted to decimal. The minimum value is 0, and the maximum value is 255. such as an ASCII code is a byte.
UTF-8 encoding: An English character equals one byte, and one Chinese (with traditional) equals three bytes.
Unicode encoding: One English equals two bytes, and one Chinese (with traditional) equals two bytes.
Symbol: English punctuation occupies one byte, Chinese punctuation is two bytes. Example: "." 1 bytes in size, Chinese period ". "Takes up 2 bytes in size.

After understanding these basic concepts, we learn the data types in the programming language, it is better to understand, but also easier to master it.



Related Article

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.