• 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

what is output ??

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again,
I really get confused with the following hexadecimal questions.What should I do to solve the folloing code??

just let me know what to do to solve this problem ?
thanx in advance.
 
Ranch Hand
Posts: 330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Convert 0xffffffc9 to binary
- to easily convert hex to binary, each hex digit is converted:
1111 1111 1111 1111 1111 1111 1100 1001
Converting to byte lops of high order bits
- high order bits removed : 1100 1001
- Using Two's complement:
- flip the bits:
110110 = 54
- Add 1:
55
- Since leftmost digit is 1 (when high order bits were removed),
value is negative:
-55
Expression should now be:
1. b += b - (i = -55);
2. b += b - (-55);
3. b += b + 55;
4. b = 0 + 55;
5. b = 55
6. Converting to hex: 37
[ December 08, 2003: Message edited by: dennis zined ]
[ December 08, 2003: Message edited by: dennis zined ]
 
Vishy Karl
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks dennis for the explanation.
 
dennis zined
Ranch Hand
Posts: 330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
By the way when casting the int to byte, after the 24 high-order bits were discarded...you only do two's complement if the leftmost digit is 1. If it is 0, you can immediately convert to decimal and proceed with the math expression.
 
reply
    Bookmark Topic Watch Topic
  • New Topic