programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Ron McLeod
• Paul Clapham
• Devaka Cooray
• Liutauras Vilda
Sheriffs:
• Jeanne Boyarsky
• paul wheaton
• Henry Wong
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Tim Moores
• Carey Brown
• Mikalai Zaikin
Bartenders:
• Lou Hamers
• Piet Souris
• Frits Walraven

# question

Greenhorn
Posts: 1
• Number of slices to send:
Optional 'thank-you' note:

7. Represent the number 6 as a hexadecimal
literal.

Rancher
Posts: 1776
• Number of slices to send:
Optional 'thank-you' note:
Hello Siddharth,

Welcome to the Ranch

Did you miss to post any previous part of your question? Because I see the numbering start from #7. If not the number 6 is represented as 6 in Hexa too.

Greenhorn
Posts: 11
• 1
• Number of slices to send:
Optional 'thank-you' note:
Integer.toHexString(6); //will do the work!!

Ranch Hand
Posts: 275
• Number of slices to send:
Optional 'thank-you' note:

Ranch Hand
Posts: 201
1
• Number of slices to send:
Optional 'thank-you' note:

siddharth lakhotia wrote:
7. Represent the number 6 as a hexadecimal
literal.

Well there are a couple of ways I know of to represent the number 6, a decimal integer, as a hexadecimal value. The easy way would be to understand that from 0 to 9 both decimal and hexadecimal are the same, so decimal 6 is also 6 in hexadecimal, its only after 9 that hexadecimal represents 10 as A, 11 as B, 12 as C, 13 as D, 14 as E, and 15 as F.

The other way would be to repeatedly divide 6 by 16 until the remainder is 0. Then the remainders in reverse order is your new hexadecimal number. I attached a graphic that explains this. There are a few webpages that talk about it too, and a few webpages with programs that do the calculation for you! : )

decimal in to hexadecimal converter with rosetta type stone graphic showing how they relate: http://www.easycalculation.com/decimal-converter.php
please find this relatively simple guide to converting base-10 to base-16: http://www.wikihow.com/Convert-from-Decimal-to-Hexadecimal

 CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad: We need your help - Coderanch server fundraiser https://coderanch.com/wiki/782867/Coderanch-server-fundraiser