Origins of SIGNED and UNSIGNED

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Positive and negative designation aside, what are the original reasons computers started using SIGNED and UNSIGNED data types the way they're implemented today ?

It just seems odd that what seems to work as a switch tells the type to either be completely positive, or to be half-and-half. I'm having trouble thinking of a good reason on my own, and I'm at a bit of a loss about what I should be searching for.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9088
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I would have to double check the exact meaning, but lets say you have a 8 bit number that is unsigned:

2^8 = 256 values (0 to 255)

Now for a signed value you can still only have 256 values split between the positives and the negatives:

2^8 = 256 values (-128 to 127)

So the main basis I think to having an unsigned value is if you do not want to use a higher bit number but want to get the maximum possible value if you know you aren't going to be using negative values. For example a 64 bit number that is unsigned:

2^64 = 8,446,744,073,709,551,616 values (0 to 8,446,744,073,709,551,615)

and one that is signed:

2^64 = 8,446,744,073,709,551,616 values (−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)

So by using an unsigned number have this many more postive numbers to play around with: 9,223,372,036,854,775,808 without having to take up more memory. If you wanted to have the signed value:

10,000,000,000,000,000,000

You would be forced to use a 128 bit number which uses alot more memory (and probably not even possible on current architecture). Not sure if that answered your question or not, but I believe that is the thinking behind this. Correct me if I am wrong.

Edit**
With regards to using 128 bit numbers I found this:

Quote:
C only available as non-standard compiler-specific extension


http://en.wikipedia.org/wiki/Integer_%2 ... science%29
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

It does outline the way SIGNED and UNSIGNED work quite nicely. Though I'm afraid I'm still wondering why it's all positive or hanf-and-half, instead of all positive or all negative.

The more I think about it, the more it seems likely to need shorter ranges of positive and negative numbers than it would be to need larger ranges of all negative numbers. I think that would be a good reason to go all positive or half-and-half like it is.

--

Now I'm a little curious how quantum bits with their "on", "off", and "both on and off" states could effect SIGNED and UNSIGNED, or binary math as a whole for that matter. :scratchhead:

1, 2, 4, 8, 16... with switches for both seems simple enough. What would the extra state do to the system ?

The first thing that comes to mind would be having the first bit be zero, one, or two, basically combining the first and second bits, then having the second bit stand for zero, two, or four. Bit three being zero, four, or eight. Basically compressing 4 bits in to 3 if I figured that right.

I don't know though.

000 [0], 100 [1], 200 [2], 110 [3], 020 [4], 120 [5], 220 [6] 111 [7], 002 [8]
102 [9], 202 [10], 112 [11], 022 [12], 122 [13], 222 [14]

-VS-

000 [0], 100 [1], 010 [2], 110 [3], 001 [4], 101 [5], 011 [6], 111 [7]

Now that seems like a big difference. I think I'm more confused now than I was in the beginning. :scratchhead:
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

Quote:
It does outline the way SIGNED and UNSIGNED work quite nicely. Though I'm afraid I'm still wondering why it's all positive or hanf-and-half, instead of all positive or all negative.


If it where all positive or all negative, you would have to check the returned value of all your math to assign them to a variable that could hold the value. Going half-and-half gives you the ability to work with negative numbers and positive numbers with out the over head.

If you can find a way to get a microchip to use trinary code I'll give you a dollar ;)

Not saying its impossible but, on and off is so simple compared to trying to represent a third state.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Quote:
If you can find a way to get a microchip to use trinary code I'll give you a dollar


How much will you give me to tell you how I did it ? :D
  • Mas Sehguh
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1853

Post 3+ Months Ago

Signed integers are the convenient ones -- that's why Java only has them. The real question, then, is why do we have unsigned integers? We have them because array sizes can be larger than half the address space. Signed integers whose size in bits is the same as the size of a pointer can't represent the size of an array that's larger than half the address space, but unsigned integers can represent the sizes of all arrays.
  • RockmanTV
  • Proficient
  • Proficient
  • RockmanTV
  • Posts: 348

Post 3+ Months Ago

This thread is a bit old but if you don't mind I'll throw in my hypothesis.

UNSIGNED and SIGNED allow you to take full advantage of the memory you have available. In today's systems it may not be as big of deal but in older systems when you had limited resources (think in KBs of RAM or what not) using SIGNED and UNSIGNED allowed you to get the most bang for your buck since in most cases you're dealing with positive values.

SIGNED values still needed to exist because occasionally you need to use negative values but for the times you didn't, UNSIGNED values allowed you to stretch that value a bit further.

Just my two cents...

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 64 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.