473,320 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

signed/unsigned byte

how can the computer tell the difference between the two?
i mean a byte is 8 bit can be 1 or 0

11111111 = 255 unsigned byte

10000000 = -128 or 128 ?

Sep 13 '07 #1
4 15244
Lamefif wrote:
:: how can the computer tell the difference between the two?
:: i mean a byte is 8 bit can be 1 or 0
::
:: 11111111 = 255 unsigned byte
::
:: 10000000 = -128 or 128 ?

It isn't the byte itself that is different, it is the instructions
used to manipulate it.
Bo Persson
Sep 13 '07 #2
"Lamefif" <Le*************@googlemail.comwrote in message
news:11*********************@50g2000hsm.googlegrou ps.com...
how can the computer tell the difference between the two?
i mean a byte is 8 bit can be 1 or 0

11111111 = 255 unsigned byte

10000000 = -128 or 128 ?
Different programming is used for signed and unsigned. The assembly
language of the processor typically provides two kinds of branch
instructions. For unsigned data a branch opcode checks the carry flag
(which is kind of like a 9th bit after an arithmetic operation). For signed
checks another branch opcode checks the sign bit, which is the 8th bit of
the byte. That is why C++ has both signed and unsigned types: It affects the
code that is generated to test arithmetic results.

Sep 13 '07 #3
Lamefif wrote:
how can the computer tell the difference between the two?
An object of 'signed char' type is signed. An object of
'unsigned char' type is unsigned. An object of type 'char'
is signed or unsigned depending on the implementation.
i mean a byte is 8 bit can be 1 or 0

11111111 = 255 unsigned byte
It's -1 on two's complement, if treated as signed.
10000000 = -128 or 128 ?
It depends on how you look at it.

0x34562ef9 - a long or a float?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 13 '07 #4
Thanks all :)

Sep 13 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Christopher Benson-Manica | last post by:
Given signed char str_a="Hello, world!\n"; unsigned char str_b="Hello, world!\n"; what is the difference, if any, between the following two statements? printf( "%s", str_a ); printf( "%s",...
4
by: Ken Tough | last post by:
Seems like a simple thing to find out, but I'm struggling. I have googled, but everything I find is about implicit conversion, not explicit. Is this implementation-specific, or does ANSI/ISO...
10
by: tinesan | last post by:
Hello fellow C programmers, I'm just learning to program with C, and I'm wondering what the difference between signed and unsigned char is. To me there seems to be no difference, and the...
64
by: ng5000 | last post by:
Hi, What's the point of a signed char? As I see it a char represents a character (not an integer, use an int type e.g. short int if you want an 8 bit number, or one of the new types, uint8 I...
22
by: juanitofoo | last post by:
Hello, I've just switched to gcc 4 and I came across a bunch of warnings that I can't fix. Example: #include <stdio.h> int main() { signed char *p = "Hola";
20
by: Hanzac Chen | last post by:
Hi, I don't understand why this could happen? The Code 1 will output `fff9' and the Code 2 will output `1' How could the `mod 8' not have effect? /* Code 1 */ #include <stdio.h> #include...
18
by: Susan Rice | last post by:
I'm comparing characters via return(str1 - str2); and I'm having problems with 8-bit characters being treated as signed instead of unsigned integers. The disassembly is using movsx ...
3
by: velpur | last post by:
Dear friends, ( Suppose we change byte orders. For example, our program reads a file as a character string and converts the byte order. ) // a simple code #define INTEL_CPU #ifdef...
3
by: toe | last post by:
I have a byte called "x". I want byte "y" to be the complement of "x" (i.e. all the bits flipped). Initially I wrote: char unsigned x, y; ... x = 72;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.