• 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

HexaDecimal value

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the Int value of this ?

int i = 0xFFFFFFF1

How do you convert this manually ?
 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
0xFFFFFFF1 in bin is 11111111111111111111111111110001.
Since the high bit is 1, it's a -ve number. So to find out the value, use two's complement: flip bits and add one.
Flip bits: 11111111111111111111111111110001
You get: 00000000000000000000000000001110, add 1 you get
00000000000000000000000000001111, which is 15.
But since the number is -ve, it's -15.
HTH,
Sashi
P.S. Check out the thread under the title "~ operator" earlier today.
[ December 15, 2005: Message edited by: Sasikanth Malladi ]
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that each hexadecimal digit represents 4 binary bits (since 2^4 = 16). For example...

Similiarly, each octal digit represents 3 binary bits (since 2^3 = 8).

Once you have the binary representation, you can proceed as Sasikanth indicated above.
 
Ram Han
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
--------------------------------------------------------------------
0xFFFFFFF1 in bin is 11111111111111111111111111110001.
Since the high bit is 1, it's a -ve number. So to find out the value, use two's complement: flip bits and add one.
------------------------------------------------------------

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

How do you say the high bit is 1 , which one you consider?
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by MuraliRam Narasimhan:
...How do you say the high bit is 1 , which one you consider?


For integral primitive values, a bit of "1" in the first position (on the left side) indicates a negative value.

The minimum value (closest to negative infinity) is a binary one followed by all zeros, and -1 is represented in binary by all ones (so that adding another 1 results in all zeros).

For example, an 8-bit byte has a range of -128 to 127...

[ December 15, 2005: Message edited by: marc weber ]
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
remember folks - this is a topic for 1.4 but not for 1.5!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic