Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Getting nybbles

Thread view: 
mikew01 - 26 Mar 2007 17:41 GMT
Hi, I need to split up a byte value into two nybbles, I understand bit
shifting is the ideal method to perform this task.

Could someone explain how to do this please.

TIA
Daniel Pitts - 26 Mar 2007 18:00 GMT
> Hi, I need to split up a byte value into two nybbles, I understand bit
> shifting is the ideal method to perform this task.
>
> Could someone explain how to do this please.
>
> TIA

Well, a nibble is 4 bits, and a byte is 8 bits.

You need to mask part of the byte using binary and (&).  00001111 in
binary = 15 dec and 0xF hex.

lowNib = myByte  & 0xF;

Then you need to make the high nibble in myByte the low nibble:

highNib = (myByte >> 4) & 0xF;

Hope this explains it. Good luck,
Daniel.
mikew01 - 27 Mar 2007 09:02 GMT
Thanks for your help.

> Well, a nibble is 4 bits, and a byte is 8 bits.
>
[quoted text clipped - 9 lines]
> Hope this explains it. Good luck,
> Daniel.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.