A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
The Java EE 7 Tutorial Volume 1 or Volume 2
this week in the
jQuery UI in Action
Conversion of negative binary number to decimal number
Joined: May 06, 2004
May 06, 2004 10:11:00
if we have a byte value EX: 11111111 where 1 in first digit place shows that its negative number, how to get back the decimal number which will be negative.
Joined: Jun 02, 2003
May 06, 2004 11:16:00
You can convert it to an int, and then convert this into a byte:
int i = Integer.parseInt ("11111111", 2); byte b = (byte) i;
The casting in the second line is needed, to avoid the compilerwarning 'possible loss of precision'.
Don't get me started about those stupid
subject: Conversion of negative binary number to decimal number
No 'E' in a big floating point number
Questions about switch ... case ?
convert negative decimal number to binary
Two's complement question
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014