extract an 7bit signed integer ?!
Author Message extract an 7bit signed integer ?!

how can i extract a 7 bit integer value, given in a 8 bit byte, to a 16 bit
integer ?!

there's the byte:

bit#    7    6    5    4    3    2    1    0
0    < 7 bit signed integer >

who can help me ?

trs

Wed, 18 Jun 1902 08:00:00 GMT  extract an 7bit signed integer ?!
simply with ":=" Example:

var a: shortint; {7 bit signed integer}
b: integer;  {16 bit, signed integer}

begin
... {a gets a value}
b:=a; {we "extract" it}
end.

I hope i didn't missunderstand your question

bye

Igor2

Quote:

> how can i extract a 7 bit integer value, given in a 8 bit byte, to a 16 bit
> integer ?!

> there's the byte:

> bit#    7    6    5    4    3    2    1    0
>           0    < 7 bit signed integer >

> who can help me ?

> trs

Wed, 18 Jun 1902 08:00:00 GMT  extract an 7bit signed integer ?!

Quote:
>simply with ":=" Example:

>var a: shortint; {7 bit signed integer}

Sorry, but shortint is 8 bits.

Quote:
>    b: integer;  {16 bit, signed integer}

>begin
>... {a gets a value}
>b:=a; {we "extract" it}
>end.

The simplest is to use asm:

var b:byte;
a:shortint

asm
mov al,b
shr al,1
sar al,1
mov a,al
end;

In Pascal one could code something like:

{\$r-}
if b and 64<>0 then a:=128 or b
else a:=b;

Osmo

Wed, 18 Jun 1902 08:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages