• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Confusion with Binary, Byte representations

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I got this code snippet from this Binary File Processing resource link.



I am just confused with the "0x00" and "0xFF" stuffs. Why should we assign the char variables to hexadecimal representations?
Hope you can help me. Thanks!

Here's the complete code by the way (writing/reading to/from a binary file)


 
author
Posts: 23901
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am just confused with the "0x00" and "0xFF" stuffs. Why should we assign the char variables to hexadecimal representations?



The representation is for the developer. The compiler doesn't care what representation you use. In general, hexidecimal is preferred for binary data because it can be easily envision -- two digits with each digit representing 4 bits easily.

However, if you feel more comfortable with decimal, feel free to use that instead...



Henry
 
Denise Advincula
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see.. Thanks a lot!
Just a note, Binary Editors are also helpful. Now I get that they represent binary data positions in hex.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic