Simba College-unity-with you 0 basic C # series (iii) calculation and type

Source: Internet
Author: User

Draft, the finished can ask me to Doc manuscript, do not turn the draft

?

Simba College: a fair and aboveboard.

Happy Mid-Autumn festival, every festive times Sze Chen, especially the wife who has not met, right, Dick Silk.

?

Today, let's explore the strange calculations, strange types in C #.

Strange calculations.

When I was just in touch with computer programming, everything seemed strange to me.

i++
I=i+1
I==i+1

What the hell is all this?

Machine language is Turing mode, and that thing is not human language, it is about manipulating registers.

Attached: Turing video address beta:

http://v.youku.com/v_show/id_XMTM0MDg0NjUxMg==.html?from=y1.7-1.2

High-level languages mimic human language, but the above-mentioned ghosts are completely invisible in human language.

No one can understand, in terms of natural language to do a lot of ellipsis.

The equal sign here has nothing to do with the equal sign of mathematics, but rather a simplified symbol for replacing natural language.

Not just the equals sign, but all the symbols that appear in the programming language, he's actually trying to say a word, not necessarily expressing the same meaning as the symbol you're familiar with in math.

i++ (he wants to say a word, let I this variable value increased by 1)
I=i+1 (he wants to say a word, let i this variable value change, change to i+1) (here at first learned very tangled we wait to explain)
I==i+1 (he wanted to say a word, judging if I was equal to i+1)

You have to remind yourself that this isn't math, it's not math, it's not math.

In high-level languages, all statements want to say a word

I=i+1, is it a little strange to say that? Let I change the value of this variable to i+1. What is their view of space and time? Rest assured, this is not the hacker Empire.

Our view of space and time is still at Newton's classical physics level. (Junior high School physics level)

"The code is a tree, the execution is sequential," said the previous. This is a matter of order. He is equivalent to take a temporary variable j=i+1, which is no time-space disturbance, and then let I=j.

It is not what is strange in space-time view, but this sentence implies a mechanism of temporary variable in the middle.

Beginners may be here around the circle for a while, no matter, more around.

= This symbol is the "let whose value change to xxx" symbol, not the equal sign in mathematics

?

3

2

1

Do you have a clear circle?

For subtraction and numerical types, it is consistent with the mathematical meaning, not specifically

And then the strange calculation that appears is this: i==i+1

This is called the logical operation, the complete wording should be as follows: BOOL B =i==i+1; The complete natural language to be expressed is: let the value of B change to Yes or no, I is equal to i+1.

All logical operations result in only yes or no, and the bool type is specifically used to indicate whether this is a yes or No. The int type specifically represents integers.

The most common use of logic types is with the If choice logic, if (i>2) hides some details, the complete wording is

BOOL B = i>2;
if (b)
{
...
}

C # unifies all the situations where logical expressions are required to use parameters of type bool.

That is to say, in C # all use logical operations, you can write a definite bool variable as above.

When you write that these questions don't get around at all, you can completely ignore them.
Now, if you write code to write a logical operation around it, you can write it down and make it easier to read.

As long as you always keep in mind that all operators are trying to say a word, they will not fall into this trap.

In fact, more than just operators, high-level language we said, the whole is a tree, each sentence is to say a word, a human word, just too much simplification, said not so good.

C # There is a special kind of calculation, bit operation, this is the category of 2, the logic clearly requires the remaining memory requirements of the now, bit operation Mirror rate is close to 0, so we do not mention this part.

Strange Kind of

Simba College-unity-with you 0 basic C # series (iii) calculation and 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.