1

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.
Show please on an example:
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

2

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

3

Re: Bit values.

On health. smile

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;

4

Re: Bit values.

wadman;
Also what further? sad

5

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.

6

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) <> 0;//a sign
end;

7

Re: Bit values.

And that not through an array byte?

8

Re: Bit values.

rgreat;
?

9

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) <> 0;//a sign
end;

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

10

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 [+]". smile

11

Re: Bit values.

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

12

Re: Bit values.

akrush;
Path_to_Intalled_FB_Server\doc\sql.extensions\README.execute_statement2.txt

13

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>>> 0001 1000 1001 1110 <<<
data: = val and $0000FFFF;
//spec: = to receive from val bits with 16 on 23
//0000 0000>>> 0000 1010 <<<0001 1000 1001 1110
spec: = (val shr 16) and $000000FF;
//calc: = to receive from val bit 24
//0000 000>>> 0 <<<0000 1010 0001 1000 1001 1110
calc: = (val shr 24) and $00000001;

Yours faithfully, Polesov.