Delphi bitwise operation NOT and OR XOR SHL SHR

Source: Internet
Author: User

delphi  bitwise Operation  not and or xor shl shrunit unit1; interface uses   windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,  dialogs, Stdctrls, Extctrls ;  type  tform1 = Class (Tform)     Button1:TButton;     button2:tbutton;    button3:tbutton;    button4:tbutton;     Button5:TButton;    Button6:TButton;    Shape1:TShape;     label1:tlabel;    label2:tlabel;    button7: Tbutton;    button8:tbutton;    procedure Button1Click (Sender:tobject);     procedure Button2click (sender:tobject);     procedure Button3Click ( Sender:tobject);     procedure Button4click (sender:tobject);     pRocedure Button5click (sender:tobject);     procedure Button6click (Sender:tobject);     procedure Button7click (sender:tobject);     procedure Button8Click (Sender: TObject);   private    {Private Declarations}  public     {public declarations}  end; var  form1:tform1; implementation {$R *.DFM } procedure Tform1.button1click (sender:tobject);var  a:word;  c:integer;begin   a: = 6;   //0000 0000 0000 0000    0000 0000 0000 0110  c: = 12;  //0000 0000 0000 0000    0000 0000 0000 1100      Four bytes 32 bits    ShowMessage (IntToStr (A and C)), End; procedure Tform1.button2click (sender:tobject); Var  a, b:word;//  a, B:integer;begin  a: = 6;  b: = 12;  showmessage (IntToStr (A and B));  //unsigned://byte:      a byte  8 bit    2 8 times           0-255 (2 of 8 parties-1)//Word:      Two bytes 16-bit    2 16-square          0-256*256 (65535)//Longword:   Four bytes +       2 32-square         0-65536*65536 (4294967295)////signed: (Take out a sign bit, indicating positive or negative)// Shortint    8          -of a byte 8-bit     2 127-127 (256/2)//smallint    two bytes 16 bit    2 16 Parties          -32767-32767 (256*256/2)//longint (Ingetger) Four bytes 32-bit  2 32-square  -2147483647-2147483647 (4294967295/2) END; //NOT//1, 0, 0, 1procedure Tform1.button3click (sender:tobject);var  a:word;begin   a: = 14;    //0000 0000 0000 1110  showmessage (INTTOSTR (nOT a));   //65521  not-> 1111 1111 1111 0001end; //and//are 1 only 1procedure Tform1.button4click (Sender: TObject); Var  a, b:word;begin  a: = 14;    //0000 0000 0000 1110  b: = 23;    //0000 0000 0001 0111  showmessage (IntToStr (A and B));//6  and->0000 0000 0000 & The nbsp;0110end; //or//bit has 1 1procedure tform1.button5click (sender:tobject); Var  a, b:word;begin   a: = 14;    //0000 0000 0000 1110  b: = 23;    //0000 0000 0001 0111  showmessage (IntToStr (A or B))//31  and->0000 0000 0001 & nbsp;1111end; //xor//bit different 1procedure Tform1.button6click (sender:tobject); Var  a, B:word;begin   a: = 14;    //0000 0000 0000 1110  b: = 23;    //0000 0000 0001 0111  showmessage (IntToStr (a XOR B));//25  and->0000 0000 0001 & nbsp;1001end; //shl//Description: Left to right 0 (out of Ignore) procedure Tform1.button7click (sender:tobject); var  a:word;  b:byte;begin   a: = 14;    //0000 0000 0000 1110  showmessage (INTTOSTR (a SHL 1));//28  and->0000 0000 0001 & Nbsp;1100  showmessage (IntToStr (a SHL 3))//112  and->0000 0000 0111  0000   b : = 12;     //0000 1100;  showmessage (INTTOSTR (b shl 4));   //192     1100 0000  showmessage (inttostr (b shl 5));   //384    11000 0000                         //  6       //    11 0000 0000        (out of ignore)  end;  //shr//Description: Right shift   left 0 (out of Ignore) procedure Tform1.button8click (sender:tobject); var  a:word;begin   a: = 14;    //0000 0000 0000 1110  showmessage (INTTOSTR (a shr 1));//7  shr->0000 0000 0000 & Nbsp;0111  showmessage (IntToStr (a shr 2))//3  shr->0000 0000 0000  0011                             //3              0000 0000 0000  0001                            //4              0000 0000 0000  0000       ( Out of ignore) end; end.

Delphi bitwise operation NOT and OR XOR SHL SHR

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.