The integrity can be achieved by A * 256 ^ 256 ^ 2 + 3 + B * C * 256 + D calculated
At first thought it was a 32-bit signed integer, can calculate the value of the wrong
Give advice or comments please!
CodePudding user response:
So calculate, then 128.0.0.0 and 0.0.0.0 calculate the decimal are 0; So is greater than the 128.0.0.0 IP are negative,Such as 128.0.0.1 be 1
128.0.0.2 is - 2
CodePudding user response:
unit Unit11;
Interface
USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
Type
TForm11=class (TForm)
Edt1: TEdit;
Btn1: TButton;
Edt2: TEdit;
Btn2: TButton;
Procedure btn1Click (Sender: TObject);
Procedure btn2Click (Sender: TObject);
Procedure FormCreate (Sender: TObject);
Private
The function ip2Int (const strIP: string) : Int64;
The function int2Ip (intIP: Int64) : string;
{Private declarations}
Public
{Public declarations}
end;
Var
Form11: TForm11;
Implementation
{$R *. DFM}
The function TForm11. Int2Ip (intIP: Int64) : string;
Var
N: int64;
The begin
Result:=';
N:=intIP SHR 24;
IntIP:=intIP xor (n SHL 24);
Result:=IntToStr (n) + '. '.
N:=intIP SHR 16;
IntIP:=intIP xor (n SHL 16);
Result: the Result=+ IntToStr (n) + '. '.
N:=intIP SHR 8;
IntIP:=intIP xor (n SHL 8);
Result: the Result=+ IntToStr (n) + '. '.
N:=intIP;
Result: the Result=+ IntToStr (n);
end;
The function TForm11. Ip2Int (const strIP: string) : Int64;
Var
LST: TStringList;
I: integer;
The begin
Result:=0;
LST:=TStringList. Create;
Try
LST. Delimiter:=';
LST. DelimitedText:=strIP;
For I:=0 to LST. Do the Count - 1
Result: the result=+ StrToInt64 (LST) [I] SHL (24 - I * 8);
The finally
LST. Free;
end;
end;
Procedure TForm11. Btn1Click (Sender: TObject);
The begin
Edt2. Text:=IntToStr (ip2Int (edt1. Text));
end;
Procedure TForm11. Btn2Click (Sender: TObject);
The begin
Edt1. Text:=int2Ip (StrToInt64 (edt2. Text));
end;
Procedure TForm11. FormCreate (Sender: TObject);
The begin
Edt1. Text:='192.168.1.1';
Btn1. Click;
end;
End.
CodePudding user response:
Have to unsigned 32-bit integerCodePudding user response:
The same as the value of the database or notCodePudding user response:
That doesn't call the decimal,CodePudding user response: