Some results are processed on the C # backend and then transmitted to the front-end Javascript or jQuery,

Source: Internet
Author: User

Some results are processed on the C # backend and then transmitted to the front-end Javascript or jQuery,

In C # Back-end processing some results are passed to the front-end Javascript or jQuery, the previous Insus. NET has done an example of "to pass the CS value to JS use" http://www.cnblogs.com/insus/archive/2011/05/04/2036271.html is implemented using the Literal control. But it is still complicated. This Insus. NET is simplified, and the value is passed to the front-end jQuery.

The user requests a webpage, sends it to the server, and then sends it to the client. Therefore, it is easy for the server to pass values to jQuery or javascript. Otherwise, it will be difficult.

I just saw a requirement on the website:

 

You can write:

Check the backend. aspx. cs:

 

When running the webpage, you can see:

 


In C language <yes?

First, move left. To move left is to move all the bits of a number to the left. In C, the <operator is used. For example:

Int I = 1;
I = I <2; // shifts the value in I two places to the left.

That is to say, the binary system of 1 is 000... 0001 (here, the number of 0 in front of 1 is related to the number of digits in int, 32-bit machine, 31 0 in gcc), shifted to 000 after 2 digits left... 0100, that is, 4 in decimal system. Therefore, if the Left shift of 1 is equivalent to multiplying by 2, then the left shift of n is multiplied by the Npower of 2 (the number of symbols is not fully applicable, this is because the left shift may cause symbol changes. The reasons are described below)

One problem that needs to be noted is the symbol bit at the leftmost end of the int type and the shift out. we know that int Is the signed integer number, and the first bit on the leftmost side is the signed bit, that is, 0 is positive and 1 is negative. Then, overflow occurs during shift. For example:

Int I = 0x40000000; // 40000000 of hexadecimal notation, 01000000 of hexadecimal notation... 0000
I = I <1;

Then, after I shifts 1 to the left, it will become 0x80000000, that is, 100000 of the binary system... 0000, the sign bit is set to 1, and the other bits are all 0, which is changed to the minimum value that can be expressed by the int type. The 32-bit int value is-2147483648, overflow. what will happen if I is moved 1 to the left? In C language, the highest bit is discarded. After 1 is discarded, the value of I is changed to 0.

A special case in the left shift is that when the number of digits in the left shift exceeds the maximum number of digits in the value type, the compiler will use the number of digits in the left shift to de-model the maximum number of digits and then shift by the remainder, for example:

Int I = 1, j = 0x80000000; // set int to 32 characters
I = I <33; // 33% 32 = 1 shifted to 1, and I changed to 2
J = j <33; // 33% 32 = 1 shifts 1 bit left, j changes to 0, and the highest bit is discarded.

When compiling this program with gcc, the compiler will provide a warning, indicating the number of places to move left> = type length. in fact, I, j moves the remainder of 1 bit, that is, 33% after 32. this rule is implemented in gcc. It is unclear whether other compilers are the same.

In short, the Left shift is: discard the highest bit, 0 fill the second bit

Now that the right shift is clear, the right shift is better understood.

The concept of right shifting is opposite to that of left shifting. It is to move several digits to the right. The operator is>.

The bitwise of the right-shift symbol is different from that of the left-shift symbol. For signed integers, for example, int type, the right-shift symbol remains unchanged. For example:

Int I = 0x80000000;
I = I> 1; // The I value will not change to 0x40000000, but 0xc0000000

That is to say, after the sign bit moves to the right, if it is positive, it fills in 0, and if it is negative, it fills in 1, that is, the arithmetic shift in assembly language to the right. similarly, when the number of digits to be moved exceeds the length of the type, the remainder is obtained and then the remainder is moved.

Negative number 10100110> 5 (assuming the word length is 8 characters), the result is 11111101.

In short, in C, the Left shift is the logical/arithmetic left shift (the two are identical), and the right shift is the arithmetic right shift, which will keep the symbol bit unchanged. in practical applications, you can use the left/right shift to perform fast multiplication/Division operations, which is much more efficient than loop operations.

For example, in C language, the Left shift <represents multiplied by 2, right shift> represents dividing by 2, which is caused by how the computer works! But if it is 7, the binary number is 0111, And the right shift is 3.5, but after the right shift, the binary number is 0011, which is 3. Different. How can I explain it ??

A: The two operands of the shift operator must be integer. The Value Type of the entire shift expression is also integer, and the rest of the full text>

& In C Language

& Can be used as the bitwise AND or address fetch Operator
The following describes two usage methods:
1. bitwise and operation bitwise AND operator "&" are binary operators. Its function is the binary phase corresponding to the two numbers involved in the operation. The result bit is 1 only when the two binary numbers are 1. Otherwise, the result bit is 0. The number of involved operations is supplemented.
For example, 9 & 5 can be written as follows: 00001001 (Binary complement of 9) & 00000101 (Binary complement of 5) 00000001 (Binary complement of 1) Visible 9 & 5 = 1.
Bitwise AND operations are usually used to clear some bits or retain some bits. For example, if a clears the high eight bits of 0 and retains the low eight bits, it can be used as a & 255 operation (255 of the binary number is 0000000011111111 ).
2. Get the address
& As The unary operator, the result is the address of the right operation object.
For example, & x returns the address of x.
The address itself is an abstract concept used to indicate the logical location of an object in the memory.

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.