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 / May 2006

Tip: Looking for answers? Try searching our database.

0x00FF Arrg...

Thread view: 
IveCal - 20 May 2006 10:15 GMT
Hello... Please do help... In knew 0x00FF is HEX but may I know how is
decimal or other systems expressed?

   StringBuffer sb = new StringBuffer();
   for( int i=0; i<bytes.length; i++ )
   {
     byte b = bytes[ i ];
     sb.append( ( int )( 0x00FF & b ) ); ==> PROBLEM!!!
    if( i+1 <bytes.length )
     {
       sb.append( "-" );
     }
   }
Please help... Thanks...
Alex Hunsley - 20 May 2006 10:28 GMT
> Hello... Please do help... In knew 0x00FF is HEX but may I know how is
> decimal or other systems expressed?
[quoted text clipped - 9 lines]
>       }
>     }

If you google for "java number literals" you find web page such as this:

http://www.samspublishing.com/articles/article.asp?p=22065&seqNum=5&rl=1

To express decimal numbers, just write the number directly:
 int value = 255;  // decimal value equal to 0xFF (aka 0x00FF)

lex
Chris Smith - 20 May 2006 20:24 GMT
> Hello... Please do help... In knew 0x00FF is HEX but may I know how is
> decimal or other systems expressed?
[quoted text clipped - 9 lines]
>       }
>     }

If Alex's reply didn't make sense, then try explaining what exactly you
mean by "==> PROBLEM!!!".  The word 'problem' is not very descriptive.  
What did you want to happen?  What's happening instead?

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Roedy Green - 25 May 2006 05:56 GMT
>      sb.append( ( int )( 0x00FF & b ) ); ==> PROBLEM!!!

I think you want a hex string.

the & automatically promotes to int so (int) does nothing.

Then you want to go back to a String, a HEX string rather than the
default  decimal one.

See http://mindprod.com/jgloss/hex.html
http://mindprod.com/applets/converter.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



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.