Programming-related digital games

Source: Internet
Author: User
Tags binary to decimal decimal to binary

Website creationProgramOne day is full of dummies.

C ++ is almost forgotten to be clean.

In fact, these are some of the most basic things. Writing a program for a period of time suddenly discovers that these most basic things are the most interesting. ------ \\\\ (˙ <> ˙ )/------

Don't say that some people like this kind of virtual stuff. It's just like an inflatable doll --! Speechless .....

Displacement operator, as long as you are familiar with binary, you can operate it skillfully.

 
Int num = 1;
Num <= 10;
Console. writeline (Num );

Shifts 10 bits left (Binary bits), equivalent to the 10th power of 2

The output result is 1024.

The conversion method between binary and decimal:

Conversion between binary and decimal: // convert the byte array to a long integer (Binary to decimal) Static long byteartolong (byte [] bytes) {int [] Nums = {1,256,512,102, 4096,8192, 16384,32768, 65536,131072, 262144}; If (bytes. length> nums. length) throw new exception ("overflow"); long num = 0; For (INT I = 0; I <bytes. length; I ++) num + = (Bytes [I] * Nums [I]); Return num;} // convert a long integer to a byte array (decimal to binary) static byte [] numtobytear (long num) {ilist <byte> DATA = new list <byte> (); long dividend = num; int indx = 0; do {long Yu = dividend % 256; dividend/= 256; data. add (byte) Yu);} while (dividend> 0); indx = 0; byte [] bytes = new byte [data. count]; foreach (byte B in data) bytes [indx ++] = B; return bytes ;}

.

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.