Topic: Bit values.

I use Delphi XE2
Prompt how correctly to receive a decimal number from a bit field.
There is a bit field, 32 bits.
Decimal number in it - 661662
looks so (with 31 on 0 bits): 0000 0000 0000 1010 0001 1000 1001 1110
In this number it is stored  3 values:
1. Date - the first 16 bits (0-15: 0001 1000 1001 1110)
2. The code of the expert - following 8 bits (16-23: 0000 1010)
3. The calculation sign - 24 bits, is now installed 0.
I twist different methods of offsets, obtaining of values and something is impossible.
var data, spec, calc, val:integer;
val: = 661662;
data: = to receive from val bits with 0 on 15
data: = to receive from val bits with 16 on 23
data: = to receive from val bit 24
As such it is possible to make. Well in any way skis do not want to go

Re: Bit values.

akrush;
Inaccuracy:
data: = to receive from val bits with 0 on 15
spec: = to receive from val bits with 16 on 23
calc: = to receive from val bit 24
As a result it would be desirable to receive:
data=6302
spec=10
calc=0

Re: Bit values.

On health.

``````TIntegerRec = packed record
case Byte of
1: (Lo: Word;
Hi: Word);
2: (LoLo: Byte;
LoHi: Byte;
HiLo: Byte;
HiHi: Byte);
end;
TInt64 = packed record
case Byte of
0: (Lo: Integer;
Hi: Integer);
1: (LoLo: Word;
LoHi: Word;
HiLo: Word;
HiHi: Word);
2: (LoLoLo: Byte;
LoLoHi: Byte;
LoHiLo: Byte;
LoHiHi: Byte;
HiLoLo: Byte;
HiLoHi: Byte;
HiHiLo: Byte;
HiHiHi: Byte);
end;``````

Re: Bit values.

Also what further?

Re: Bit values.

akrush;
Coercion of types... TIntegerRec (myVal) also look that there.
Or you enter in the calculator necessary  in a binary format, you switch in decimal and turned out number you bring in a constant. Then on and with this number you look at result.

Re: Bit values.

akrush;
If confused nothing with bits, approximately so. Through bit masks.

``````var V:DWORD;
begin
V: = 661662;
Date: = V and \$0FFFF;//date
Code: = (V and \$08FFF0000) shr 16;//the code
Flag: = (V and \$F0000000) &lt;&gt; 0;//a sign
end;``````

Re: Bit values.

And that not through an array byte?

rgreat;
?

Re: Bit values.

DarkMaster wrote:

akrush;
If confused nothing with bits, approximately so. Through bit masks.

``````var V:DWORD;
begin
V: = 661662;
Date: = V and \$0FFFF;//date
Code: = (V and \$08FFF0000) shr 16;//the code
Flag: = (V and \$F0000000) &lt;&gt; 0;//a sign
end;``````

confused. There should be masks \$07FFF0000 and \$80000000 for the code and a sign. I will be corrected

Re: Bit values.

akrush wrote:

Prompt what request it is necessary to fulfill during connection to Export.fdb to outweigh all data from one DB in another.

These are 2 different connections, one request will not turn out.
P.S.Tak i needed to name a subject "All questions from me in one subject [+]".

Re: Bit values.

EXECUTE STATEMENT... ON EXTERNAL... - all in one can be unscrewed. Since  2.5

akrush;

Re: Bit values.

akrush wrote:

I Use Delphi XE2
Prompt how correctly to receive a decimal number from a bit field.

``````val: = 661662;//0000 0000 0000 1010 0001 1000 1001 1110
//data: = to receive from val bits with 0 on 15
//0000 0000 0000 1010&gt;&gt;&gt; 0001 1000 1001 1110 &lt;&lt;&lt;
data: = val and \$0000FFFF;
//spec: = to receive from val bits with 16 on 23
//0000 0000&gt;&gt;&gt; 0000 1010 &lt;&lt;&lt;0001 1000 1001 1110
spec: = (val shr 16) and \$000000FF;
//calc: = to receive from val bit 24
//0000 000&gt;&gt;&gt; 0 &lt;&lt;&lt;0000 1010 0001 1000 1001 1110
calc: = (val shr 24) and \$00000001;``````

Yours faithfully, Polesov.