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.