[Hackrf-dev] Possibly Defective HackRF One?

Jeroen Massar jeroen at massar.ch
Thu Oct 30 10:29:31 EDT 2014


On 2014-10-30 15:00, Scott Halligan wrote:
[..] I'm a complete train wreck
> when it comes to understanding what you mean regarding unsigned vs.
> signed samples.

Wikipedia has these articles related to it:
https://en.wikipedia.org/wiki/Signedness
https://en.wikipedia.org/wiki/Signed_number_representations

But that does not IMHO really explain it directly, hence:

The "sign" in signed means that there is a '+' or '-' sign in front of
the number.

Thus signed has a '+' or a '-', positive or negative.
Unsigned does not. Unsigned is thus always a positive number.

In computing that is represented by having the first bit as 'positive'
(typically the bit is then '0') or negative, the first bit is then '1'.

If we have _unsigned_ 8 bit samples we have a range of    0 till 255.
If we have   _signed_ 8 bit samples we have a range of -127 till +127.

binary		unsigned 	signed
-------------------------------------------------
0000 0000	0		0
0000 0001	1		1
0000 0010	2		2
0000 0011	3		3
0000 0100	4		4
0000 0101	5		5
0000 0110	6		6
0000 0111	7		7
...
0111 1100	125		125
0111 1110	126		126
0111 1111	127		127
1000 0000	128		-0
1000 0001	129		-1
1000 0010	130		-2
1000 0011	131		-3
...
1111 1010	250		-122		(effectively -128)
1111 1011	251		-123
1111 1100	252		-124
1111 1101	253		-125
1111 1110	254		-126
1111 1111	255		-127


Hence when the hardware and software have a different idea of what the
format is you got a problem.

Eg, if the hardware emits 8 bit _unsigned_ sample of 250, the software
that is unsigned mode will read it as -122.

The same goes for 16 bit and 32 bit etc of course. The first bit is the
'sign' in signed numbers.

Hope that clarifies it at least a little bit.

Greets,
 Jeroen



More information about the HackRF-dev mailing list