My Opera is closing 1st of March

simple

Subscribe to RSS feed

我的perl学习笔记,perl中的运算(-_-这贴死掉)

写到0:29分,提交的时候,网络突然断的了,写的东西都没有了。受不了ie了。失望了。
  1. 算术运算。perl中+,-,*,/。
    **表示乘方
    $x = 9 ** 2;        # 9 squared, or 81
    $x = 2 ** 3;        # 2 * 2 * 2, or 8
    $x = 43 ** 1;       # this is just 43
    

    perl在32位机器上能存储的最大无符号整数是4,294,967,295 ,带符号整数为2,147,483,647 。相当于2**32-1和2**31-1.
    %在perl中是取余运算符,后面不能跟0或0.x
    -,一元否定,相当于*-1。
  2. 比较运算符。
    ==,表示左右两边值相等。相等为1,不等为0。
    整型的比较运算符
    Operator Description  
    < Less than 
    > Greater than 
    == Equal to 
    <= Less than or equal to  
    >= Greater than or equal to  
    != Not equal to 
    <=> Comparison returning 1, 0, or -1  
    

    <=>这个符号比较特殊,它返回3个中的一个值,当两者相等返回0,前者大返回1,后者大返回-1.

    字符串的比较运算符
    String operator Comparison operation  Equivalent numeric operator 
    lt  Less than <  
    gt  Greater than >  
    eq  Equal to ==  
    le  Less than or equal to <=  
    ge  Greater than or equal to >=  
    ne  Not equal to !=  
    cmp  Compare, returning 1, 0, or -1 <=>  
    

    虽然perl能在数值和字符串之间互相转换,但是用比较运算符计算下来的结果却不一定相同的。不然也不会有算术比较和字符串比较了。
    计算机中往往有舍如误差,所以在perl中比较两个算术运算产生的浮点数,可能结果并不如自己想象的那样。

    p