国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
1. Classification of machine language" >1. Classification of machine language
Machine language" >Machine language
Assembly language" >Assembly language
High-level language" >High-level language
二. 進(jìn)制" >二. 進(jìn)制
二進(jìn)制" >二進(jìn)制
八進(jìn)制" >八進(jìn)制
十進(jìn)制" >十進(jìn)制
十六進(jìn)制" >十六進(jìn)制
進(jìn)制轉(zhuǎn)換" >進(jìn)制轉(zhuǎn)換
三. 原碼、反碼、補(bǔ)碼" >三. 原碼、反碼、補(bǔ)碼
原碼" >原碼
反碼" >反碼
Complement code" >Complement code
Notes" >Notes
Home Java JavaBase I secretly looked at some computer basics, and from now on learning Java is like cheating!

I secretly looked at some computer basics, and from now on learning Java is like cheating!

Jul 26, 2023 pm 05:30 PM
java

Before learning Java, I would like to ask a question. Do you think it is necessary to learn computer basics?

Many people think that there is no need to read those boring and obscure basic knowledge. It is better to start directly from HelloWorld. First touch the program, get an impression, and the code will run, and then gradually learn the syntax of the program in depth, and finally use it. Program building projects, that is, practical learning methods.

First of all, I do not deny this way of learning. It is indeed more suitable for some students, especially those who are anxious to find a job. Learn how to use it first. As for the principle, you can slowly learn it later. Dig deeper, after all, nothing is more important than bread?

But for our students who are learning logarithms from scratch, I still recommend starting with some basic knowledge of computers to understand the ideas and common sense of programming, which will also be very helpful for our future study. It's like building a house. Some people build thatched houses, some build mud houses, and some people want to build a two-story Western-style house. The depth of the foundation directly determines the level of future achievements.

So now let’s briefly understand some basic knowledge of computers.

1. Classification of machine language

Machine language

Machine language is a language that a computer can directly recognize. It is a computer language expressed directly in binary code instructions. It is a code composed of a string of 0s and 1s, with a certain number of digits, and is divided into several segments. The coding of each segment represents a different meaning. For example, the following is a simple string of machine codes:

010100100000  // 520

So many people ask, why is the machine code composed of 0 and 1?

Because the machine code needs to control the computer hardware to respond to the program instructions, 0 represents low potential, 1 represents high potential, so that a logic circuit can be generated, which is equivalent to controlling a switch. 0 is closed and 1 is open. .

Assembly language

Assembly language is a language for developers. Since the machine language is all 0 and 1, it is difficult for developers to directly control and use it, so Some special symbols need to be used as markers for binary code. Developers input these special symbols to complete the issuance of instructions and let the computer work for us. These special symbols are assembly language. Computers cannot directly recognize assembly language, and a software is required to translate assembly language into machine language. The difference between it and machine language lies in the representation method of instructions. The main body of assembly language is assembly instructions. Compared with machine instructions, programmers are easier to remember.

MOV AX,1234H  //匯編指令: 寄存器AX的內(nèi)容送到1234H中
101110000011010000010010 //機(jī)器指令

High-level language

High-level languages ??are common such as: c, c, java, python, php, etc.

It is closer to our normal thinking. Its biggest feature is that it is easy to write and the code is readable. To achieve the same function, it takes less time to use high-level languages, the program code is shorter, and it is easier to read. Second, high-level languages ??are portable, that is, a piece of code can be run on different types of computers with little or no modification.

print('Hello World')   // python版HelloWorld

我們從這個(gè)程序可以看出來,高級(jí)語言屏蔽了機(jī)器內(nèi)部指令運(yùn)行細(xì)節(jié),我們可以像寫作一樣書寫程序,而不用關(guān)心語言內(nèi)部的實(shí)現(xiàn)細(xì)節(jié),這大大提高了我們的開發(fā)效率,節(jié)約開發(fā)成本

當(dāng)然,其缺點(diǎn)也很明顯,使用高級(jí)語言編寫的程序運(yùn)行時(shí),需要先將其翻譯成低級(jí)語言計(jì)算機(jī)才能運(yùn)行它,在翻譯過程中可能會(huì)產(chǎn)生一些多余的部分,運(yùn)行效率低些。另外,對(duì)硬件的可控性相對(duì)于低級(jí)語言弱些,目標(biāo)代碼量較大。


二. 進(jìn)制

推薦使用在線工具進(jìn)行進(jìn)制轉(zhuǎn)換

https://tool.oschina.net/hexconvert/

二進(jìn)制

由數(shù)字0和1組成,逢二進(jìn)一,比如機(jī)器碼就是二進(jìn)制的,是最簡(jiǎn)單的計(jì)算機(jī)可讀懂的代碼,例如 0101(表示十進(jìn)制數(shù)字5)。

八進(jìn)制

由1到7組成的數(shù)字串,數(shù)字最大不會(huì)超過7,逢八進(jìn)一,例如 157(表示十進(jìn)制數(shù)字111)

十進(jìn)制

我們?nèi)粘J褂玫臄?shù)字都是十進(jìn)制類型的,逢十進(jìn)一,例如 0123456789。

十六進(jìn)制

由1到9,a-f(或者是A-F,分別代表10-15)組成的數(shù)字串,數(shù)字最大不會(huì)超過15,其中字母是不區(qū)分大小寫的,逢十六進(jìn)一,例如0F83(表示十進(jìn)制數(shù)3971)

進(jìn)制轉(zhuǎn)換

1. K進(jìn)制與十進(jìn)制數(shù)的轉(zhuǎn)換

假設(shè)有一個(gè)n+1位的K進(jìn)制數(shù),它的形式如下:

AnAn-1…A3A2A1A0
則它的大小為:(也就是對(duì)應(yīng)的我們能看懂的十進(jìn)制數(shù)為)

A0 * K^0 + A1 * K^1....+ An * K^n      //K^n表示K的n次方

二進(jìn)制數(shù):10101 轉(zhuǎn)換成 十進(jìn)制數(shù)為:21

 1*2^4 + 0*2^3 + 1*2^2 + 0*2^1+1*2^0 = 21

2. 十進(jìn)制與k進(jìn)制的轉(zhuǎn)換

短除法。

舉個(gè)栗子:

I secretly looked at some computer basics, and from now on learning Java is like cheating!


從圖可以看出,用十進(jìn)制數(shù)21一直除以2,每次得到的余數(shù)倒數(shù)就是最后的二進(jìn)制數(shù)10101。同樣,十進(jìn)制轉(zhuǎn)八進(jìn)制、十進(jìn)制轉(zhuǎn)十六進(jìn)制都是一樣的套路,非常簡(jiǎn)單。



3. 二進(jìn)制與八進(jìn)制和十六進(jìn)制之間轉(zhuǎn)換


8是2的3次方,16是2的4次方,所以這之間的轉(zhuǎn)換存在一種快捷方法。以2轉(zhuǎn)8示例,將2進(jìn)制從低位到高位,每3個(gè)一組,如果是十六進(jìn)制就每4個(gè)一組,高位不足3位的補(bǔ)0,然后將每組依次轉(zhuǎn)換成對(duì)應(yīng)的十進(jìn)制,得到的結(jié)果就是對(duì)應(yīng)的8進(jìn)制或者16進(jìn)制。

二進(jìn)制10101100101轉(zhuǎn)八進(jìn)制:2545

I secretly looked at some computer basics, and from now on learning Java is like cheating!

二進(jìn)制10101100101轉(zhuǎn)十六進(jìn)制:565
I secretly looked at some computer basics, and from now on learning Java is like cheating!

三. 原碼、反碼、補(bǔ)碼

在計(jì)算機(jī)中,最小的單位是位,也稱為比特(bit)。而另一個(gè)常用單位是字節(jié),一個(gè)字節(jié)是8位,也就是8比特,所以我們常用的二進(jìn)制表示法是8位。

原碼

原碼是一種非常常見的二進(jìn)制表示形式。在原碼中,為了區(qū)別正數(shù)和負(fù)數(shù),將二進(jìn)制中的最高位作為符號(hào)位,如果是0表示正數(shù),如果是1表示負(fù)數(shù)。

舉個(gè)栗子:

0000 0001   // 表示 1
1000 0001   // 表示 -1


反碼

不知道大家有沒有注意到原碼的一個(gè)問題,那就是負(fù)數(shù)參與計(jì)算的時(shí)候,比如

I secretly looked at some computer basics, and from now on learning Java is like cheating!

出現(xiàn)了一個(gè)大問題,就是1 + (-1) 不等于0,而等于 -2。


這可咋整?

In order to solve this problem, smart computer predecessors thought of reverse coding. The rules for converting original code to inverse code are: The inverse code of a positive number is itself, the inverse code of a negative number is that the sign bit remains unchanged, and other bits are inverted. The rule of negation is that if it is 0, it becomes 1, and if it is 1, it becomes 0.
Let’s take a look at the calculation of converting to the inverse code:

I secretly looked at some computer basics, and from now on learning Java is like cheating!

The result obtained is 1111 1111.

Hey? This is wrong, why is it not 0?

Don’t worry, this is just the calculation result of the inverse code. We convert the inverse code into the original code 1111 1111 —> 1000 0000, and get -0, which is 0, which is completely in line with the expected result and solved. Calculation problem of original code.


Complement code

The complement code solves the problem of negative number calculation, but there is still one problem that has not been solved, which is -0. Due to the existence of the sign bit of the highest bit of a negative number, the original eight-bit binary number can represent 2 to the 8th power, that is, 256 numbers. However, using the original code and the complement code can only represent 255, which is very uncomfortable for us. , so how can we make up for this missing number?

The bald programmers also came up with the corresponding solution - code complement.

Rules for converting original code to complement code: The complement code of a positive number is itself, the complement code of a negative number is that the sign bit remains unchanged, and the remaining digits are inverted (that is, they become the complement code) and then added 1.

For example:

Original code: 0000 0001, complement code: 0000 0001
Original code: 1000 0001, complement code: 1111 1111

Calculate:

I secretly looked at some computer basics, and from now on learning Java is like cheating!

#As can be seen from the above, using complement calculation we get 0 (instead of -0), which solves the problem of one less number.


In the complement code, it is specified that 0 is represented as 0000 0000, and 1000 0000 is represented as -128. Note that this is a rule.


Notes

  1. One's complement and one's complement cannot be directly used to convert binary to decimal. To get the corresponding size into the corresponding decimal system, you should first convert it into the original code. In other words, the original code is a form of expression that is directly related to the size

  2. In computer systems, values ????are always represented and stored in the form of complement numbers

  3. The original code, complement and complement of positive numbers are the same

  4. The original code of negative numbers is inverted: the sign bit remains unchanged, and the remaining bits are inverted.

  5. Negative numbers are converted to complement: the sign bit remains unchanged, and the remaining bits are inverted and then plus one

  6. Negative numbers are complemented to complement: the sign bit remains unchanged , the remaining bits are reduced by one

  7. The negative number is converted to the original: the sign bit remains unchanged, the remaining bits are reduced by one and then inverted

The above is the detailed content of I secretly looked at some computer basics, and from now on learning Java is like cheating!. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
How to handle transactions in Java with JDBC? How to handle transactions in Java with JDBC? Aug 02, 2025 pm 12:29 PM

To correctly handle JDBC transactions, you must first turn off the automatic commit mode, then perform multiple operations, and finally commit or rollback according to the results; 1. Call conn.setAutoCommit(false) to start the transaction; 2. Execute multiple SQL operations, such as INSERT and UPDATE; 3. Call conn.commit() if all operations are successful, and call conn.rollback() if an exception occurs to ensure data consistency; at the same time, try-with-resources should be used to manage resources, properly handle exceptions and close connections to avoid connection leakage; in addition, it is recommended to use connection pools and set save points to achieve partial rollback, and keep transactions as short as possible to improve performance.

How to work with Calendar in Java? How to work with Calendar in Java? Aug 02, 2025 am 02:38 AM

Use classes in the java.time package to replace the old Date and Calendar classes; 2. Get the current date and time through LocalDate, LocalDateTime and LocalTime; 3. Create a specific date and time using the of() method; 4. Use the plus/minus method to immutably increase and decrease the time; 5. Use ZonedDateTime and ZoneId to process the time zone; 6. Format and parse date strings through DateTimeFormatter; 7. Use Instant to be compatible with the old date types when necessary; date processing in modern Java should give priority to using java.timeAPI, which provides clear, immutable and linear

Comparing Java Frameworks: Spring Boot vs Quarkus vs Micronaut Comparing Java Frameworks: Spring Boot vs Quarkus vs Micronaut Aug 04, 2025 pm 12:48 PM

Pre-formanceTartuptimeMoryusage, Quarkusandmicronautleadduetocompile-Timeprocessingandgraalvsupport, Withquarkusoftenperforminglightbetterine ServerLess scenarios.2.Thyvelopecosyste,

Understanding Network Ports and Firewalls Understanding Network Ports and Firewalls Aug 01, 2025 am 06:40 AM

Networkportsandfirewallsworktogethertoenablecommunicationwhileensuringsecurity.1.Networkportsarevirtualendpointsnumbered0–65535,withwell-knownportslike80(HTTP),443(HTTPS),22(SSH),and25(SMTP)identifyingspecificservices.2.PortsoperateoverTCP(reliable,c

How does garbage collection work in Java? How does garbage collection work in Java? Aug 02, 2025 pm 01:55 PM

Java's garbage collection (GC) is a mechanism that automatically manages memory, which reduces the risk of memory leakage by reclaiming unreachable objects. 1.GC judges the accessibility of the object from the root object (such as stack variables, active threads, static fields, etc.), and unreachable objects are marked as garbage. 2. Based on the mark-clearing algorithm, mark all reachable objects and clear unmarked objects. 3. Adopt a generational collection strategy: the new generation (Eden, S0, S1) frequently executes MinorGC; the elderly performs less but takes longer to perform MajorGC; Metaspace stores class metadata. 4. JVM provides a variety of GC devices: SerialGC is suitable for small applications; ParallelGC improves throughput; CMS reduces

Using HTML `input` Types for User Data Using HTML `input` Types for User Data Aug 03, 2025 am 11:07 AM

Choosing the right HTMLinput type can improve data accuracy, enhance user experience, and improve usability. 1. Select the corresponding input types according to the data type, such as text, email, tel, number and date, which can automatically checksum and adapt to the keyboard; 2. Use HTML5 to add new types such as url, color, range and search, which can provide a more intuitive interaction method; 3. Use placeholder and required attributes to improve the efficiency and accuracy of form filling, but it should be noted that placeholder cannot replace label.

Comparing Java Build Tools: Maven vs. Gradle Comparing Java Build Tools: Maven vs. Gradle Aug 03, 2025 pm 01:36 PM

Gradleisthebetterchoiceformostnewprojectsduetoitssuperiorflexibility,performance,andmoderntoolingsupport.1.Gradle’sGroovy/KotlinDSLismoreconciseandexpressivethanMaven’sverboseXML.2.GradleoutperformsMaveninbuildspeedwithincrementalcompilation,buildcac

go by example defer statement explained go by example defer statement explained Aug 02, 2025 am 06:26 AM

defer is used to perform specified operations before the function returns, such as cleaning resources; parameters are evaluated immediately when defer, and the functions are executed in the order of last-in-first-out (LIFO); 1. Multiple defers are executed in reverse order of declarations; 2. Commonly used for secure cleaning such as file closing; 3. The named return value can be modified; 4. It will be executed even if panic occurs, suitable for recovery; 5. Avoid abuse of defer in loops to prevent resource leakage; correct use can improve code security and readability.

See all articles