Home > Back-end >  Rookie question, data type error for help
Rookie question, data type error for help

Time:01-24

The function TForm1. Gs_xor (a1, a2, a3: LongWord) : LongWord;
Var I, Flag, the returnvalue: LongWord;
The begin
The returnvalue:=0;
For I:=1 to 32 do
The begin
IF (a1 mod 2)=(a3 mod 2) then flag:=0 else flag:=1;
A1: a1 div=2;
A3: a3 div=2;
The returnvalue: returnvalue=+ (flag * Power (2, (I - 1)));
end;
Result: the returnvalue=;
end;
The above function, the execution Power (2, (I - 1)), happen
[Error] Unit1. Pas (40) : Incompatible types: 'Cardinal' and 'Extended'
Can you tell me how to modify the data type

CodePudding user response:

The parameters of the power is a floating point number,,,

CodePudding user response:

Power (2.0, (double) (I) - 1

CodePudding user response:

Power (2.0, (double) (I) - 1
There are Double this function?

CodePudding user response:

What function,,, this is I casts into double, double double-precision floating-point type,,,

CodePudding user response:

The returnvalue: returnvalue=+ trunc (flag * Power (2, (I - 1)));
  • Related