• Post Reply Bookmark Topic Watch Topic
  • New Topic
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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Octal representation

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can anyone respond to this, please..........
How will you represent 7 in octal?
Thanks,
sdev
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sdev:

Can anyone respond to this, please..........
How will you represent 7 in octal?
Thanks,
sdev



int 7 = octal 07 = hex 0x0007
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you tell me the funda behind this conversion ? I see from the book that Octal is prefixed with O & Hex is prefixed with OX,
Suppose if we take the same example as in RHE for 28,
How do we get this Hex conversion 0x1C & octal of 034 ?
Thanks,
Hema
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
d- decimal ; h-hexa ; o-octal
d h o
1 0x1 01
2 0x2 02
3 0x3 03
4 0x4 04
5 0x5 05
6 0x6 06
7 0x7 07
8 0x8 010
9 0x9 011
10 0xA 012
11 0xB 013
12 0xC 014
13 0xD 015
14 0xE 016
15 0xF 017
16 0x10 020
17 0x11 021
18 0x12 022
19 0x13 023
20 0x14 024

0423 octal = (3 * 1) + (2 * 8) + (4 * 64) in decimal
0x423 hexa = (3 * 1) + (2 * 16) + (4 * 256) in decimal
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is how i do it:
first convert any int to binary
then if it is hex you need then every four binary digits summed
represent one hex digit
Ex.
int 28 bin 11100
for hex break bin into quads 0001 : 1100 this gives 0x001C
for oct break bin into trips 011 : 100 this gives 034
hope this helps
 
Hema
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys,I got the point.
-Hema
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Steve,
can u explain ur method in more detail?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic