Computer problems,Computer help
*AX SOFT>>>Programming & Design

Cout << "0123456789ABCDEF"[((n >> i*4) & 0xF)]; Any one plz can explain the meaning of this line,


Cout << "0123456789ABCDEF"[((n >> i*4) & 0xF)]; Any one plz can explain the meaning of this line,

It prints the hexadecimal value of n, where i is the digit number.

Each hexadecimal digit represents 4 bits, so you start by looping i from 0 to b/4, where b is the number of bits in n (8 for a char, 16 for a short int, 32 for a long int etc). The part of the code that is "n >> i * 4" shifts the bits in n right by the required amount while ".. & 0x0F" masks off any higher bits. What you are left with is exactly 4 bits containing the digit you are printing i.e. a number from 0 to 15. This is then used to index a string to send the appropriate char to cout.

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • C or c ++ language help?

    theres ebooks and all that but id suggest buying a book from chapters or something, i have the C++ in 21 days book, my first starting out book, taught me alot, i still use as a reference if im not ...

  • Selling Linux?

    it can be sold, if you make an upgrade, anyway, most of them get money from tech support.

    ...
  • Can anyone help me on Infragistics WebGrid Component for JSF?

    There are several good websites to help you with WebGrid. Infragistics own Help Centre: ...

  • What could be the salary if iam a certified sap professional?

    Info on SAP ... ...

  • Inport picture for vb 6?

    if txtTitle.text = "Dejavu" then pctDVD.picture = loadpicture("F:\School\IPT\Year 12\VB\Assignment\Pictures\Dejavu.jpg") end if

    ...
  • I wrote an Excel macro for saving a sheet of Excel Book by reference of a cell text. I want to do is if that f

    Use "on Error go to " a new subroutine say "add()" In this one ("add()")you do a "open" on the existing workbook. You do worksheet.copy on the "home&qu...

  • Can someone please tell me how to make a website?

    You can find step by step guide on how to make a website at website like ...

  • C programming Probelem..Money changer?

    You currently have the following currency. Peso Notes 5 10 20 50 100 200 500 1000 centavos 1 5 10 25 Take the input and divide it in turn by each amount starting with the highest...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster