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  
 
 [ 3 post ] 

 Relevant Pages 

1. Converting negative integer to signed 2's compliment binary representation

2. storing a list of integers in one integer.

3. TechTips: Database corruption - signs and symptoms

4. TTable.Filter and Minus-Sign in Fieldnames

5. Urgent: Euro sign in TurboPascal

6. Unsigned and Signed

7. Signing On a SQL Database

8. SoCal DDD Book Signing

9. Ticker Tape/ LED Sign???

10. Chancing ASCII Signs

11. Vanishing SQRT-sign on graphic screen

12. Extracting data from a Maximizer database

 

 
Powered by phpBB® Forum Software