>> sign extension for computer signed numbers

Source: Internet
Author: User

Here we first explain the relevant laws, the situation is to take less bits of the signed storage space to remove data and put in more symbolic storage space, such as: Char→short.

Rule: The original space symbol bit is repeatedly populated to the remaining bits in the new space.

eg. (negative case, positive number same)

char:1000 0000→

short:1111 1111 1000 0000

-------------------------------------------------------------------------------------------------

Prove:

A = (1000 0000) 2 = (-27) 10 = (-128) 10

B = (1111 1111 1000 0000) 2 = ( -215+214+213+......+28+27) 10

= (214 (1-2) + 213 +......+27) 10

= ( -214+213+......+27) 10

= ( -27) ten = ( -128) ten = A

The example is to be validated.

---------------------------------------------------------------------------------------------

Proof (General):

Set a = (1X) 2 = ( -2n-1) + (X) 2

B = (11......1 1X) 2 = ( -2m-1+2m-2+......+2n+2n-1) + + (X) 2

= ( -2n-1) + (X) 2 = A

Evidence.

>> sign extension for computer signed numbers

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.