S
Subrahmanyam Arya
Hi Folks ,
I am trying to solve the problem of reading the numbers correctly
from a serial line into an intel pentium processor machine .
I am reading 1 byte and 2byte data both positive and negative
quantities .
Can any one tell me what are the things i should bear in mind .
I did some small c-program tests and found out that the intel
processor uses
signed 2's complement for representing negative numbers .
The data coming over the serial line is from some third party devices
..
I am assuming that the positive numbers are always in signed magitude
form ,
so no special care needs to be taken except for byte ordering . IS
this right .
Where as for negative numbers we need to know in what format the data
is coming
and convert into signed 2's complement form so that the rest of the
math or type
casting to some other types for example int or float etc will be
correct .
Is this correct .
Am i right when i said the negative numbers are only in 2's complement
form in
intel machines.
I am thinking the same applies wether it is 1 byte , 2 byte or 4 byte
quantities. IS this right .
We are running QNX OS , but i guess this problem is not related to the
OS .
Please give me some right directions , alert me to the pitfalls here .
Thanks in advance
-Subra
I am trying to solve the problem of reading the numbers correctly
from a serial line into an intel pentium processor machine .
I am reading 1 byte and 2byte data both positive and negative
quantities .
Can any one tell me what are the things i should bear in mind .
I did some small c-program tests and found out that the intel
processor uses
signed 2's complement for representing negative numbers .
The data coming over the serial line is from some third party devices
..
I am assuming that the positive numbers are always in signed magitude
form ,
so no special care needs to be taken except for byte ordering . IS
this right .
Where as for negative numbers we need to know in what format the data
is coming
and convert into signed 2's complement form so that the rest of the
math or type
casting to some other types for example int or float etc will be
correct .
Is this correct .
Am i right when i said the negative numbers are only in 2's complement
form in
intel machines.
I am thinking the same applies wether it is 1 byte , 2 byte or 4 byte
quantities. IS this right .
We are running QNX OS , but i guess this problem is not related to the
OS .
Please give me some right directions , alert me to the pitfalls here .
Thanks in advance
-Subra