Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Murach's Java Servlets and JSP
this week in the
Java in General
Two's complement significance
Joined: Jan 11, 2001
Jan 23, 2001 09:34:00
What is the significance of representing number in two's complement?
Joined: Sep 18, 2000
Jan 23, 2001 09:43:00
It allows for all bits to be represented while eliminating the embarrassing problem of having a positive and negative zero.
for example: an 8 bit number allows values of -128 to 127.
[This message has been edited by Steve Fahlbusch (edited January 23, 2001).]
Joined: Jun 03, 2000
Jan 23, 2001 10:19:00
Steve is correct.
For more discussion on this please refer to a
a discussion on Signed and Unsigned numbers
- which elaborates the discussion.
Take a Minute, Donate an Hour, Change a Life
I agree. Here's the link:
subject: Two's complement significance
Using ~ (Unary bitwise complement) for Zero
Reg. Bitwise NOT
Casting from long to byte
Right shift using array
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014