zoukankan      html  css  js  c++  java
  • 关于运算符

    运算符包括:
    @  not  ^  *  /  div  mod  and  shl  shr  as  +  -  or  xor  =  >  <  <>  <=  >=  in  is
    
    其中 @  not  ^ 是一元运算符;  +  - 有时是一元,有时是二元; 其他都是二元运算符.
    
    一元运算符在运算数的前面, ^ 例外,也可以在后面,如: P^; 二元运算符在运算数中间.
    
    运算符的行为随运算数的类型而变,譬如: not , 面对整数是对位求反; 面对布尔是逻辑非运算.
    
    除了 ^  is  in,其它运算可应用在Variant(变体类型)上.
    
    
    算术运算符: 
    +  -  *  /  div  mod
    
    
    布尔运算符:
    not  and  or  xor
    
    
    位运算符: 
    not  and  or  xor  shl  shr
    
    x shl y = x * 2^y
    s shr y = x / 2^y
    如果x是一个integer, 那么 x shl 40 = x shl 8, 因为integer的大小是32位.
    
    
    字符串运算符: 
    +
    
    
    指针运算符: 
    +  -  ^  =  <>
    
    + - 一般只对字符指针; 无类型指针(Pointer)在 ^ 前必须进行类型转换.
    
    
    集合运算符: 
    +  -  *  <=  >=  =  <>  in
    
    +(并集)
    -(差集)
    *(交集)
    <=(子集)
    >=(超集)
    
    
    关系运算符: 
    =  <>  <  >  <=  >=
    
    两个运算数必须类型一直(整数和实数除外);
    对字符和字符串,是比较每个字符在字符集中的顺序;
    其中 =  <>  <=  >= 可用于集合;
    =  <> 可用于指针和类与类型;
    <  >  <=  >= 可用于PChar.
    
    
    类运算符: 
    as  in
    
    as也用于接口;
    关系运算符 =  <> 也用于类型.
    
    
    @运算符: 
    @
    
    @返回变量/函数/过程或方法的地址,就是指向运算数的指针;
    {$T-}(编译器默认)时,@X返回通用指针; {$T+}@X返回X的类型指针;
    @F(F代表一个过程或方法),返回F的入口点,@F总是Pointer;
    要获取类的方法的指针,必须用类名来限定方法: @TMyCalss.Method
    
    
    运算符优先级:
    @  not
    *  /  div  mod  and  shl  shr  as
    +  -  or  xor 
    =  <>  <  >  <=  >=  in  is
    
    
    另外:
    
    is比较符是用在对象之间; 其他类型之间的比较用 = .
    
    Inc/Dec 分别类似其他语言中的++/--, 如:
    Inc(i); Dec(i); Inc(i,3); Dec(i,3);
    

  • 相关阅读:
    Minimum Depth of Binary Tree leetcode java
    Maximum Depth of Binary Tree leetcode java
    Symmetric Tree leetcode java
    Same Tree leetcode java
    Binary Tree Postorder Traversal leetcode java
    Binary Tree Preorder Traversal leetcode java
    Binary Tree Inorder Traversal leetcode java
    Combinations leetcode java
    一键清除Centos iptables 防火墙所有规则
    阿里云centos7.7x64安装open,并配置ip转发和nat伪装
  • 原文地址:https://www.cnblogs.com/del/p/968642.html
Copyright © 2011-2022 走看看