home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / perl5 / integer.z / integer
Encoding:
Text File  |  2002-10-03  |  1.3 KB  |  67 lines

  1.  
  2.  
  3.  
  4. iiiinnnntttteeeeggggeeeerrrr((((3333))))                                                          iiiinnnntttteeeeggggeeeerrrr((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      integer - Perl pragma to compute arithmetic in integer instead of double
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          use integer;
  13.          $x = 10/3;
  14.          # $x is now 3, not 3.33333333333333333
  15.  
  16.  
  17. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  18.      This tells the compiler to use integer operations from here to the end of
  19.      the enclosing BLOCK.  On many machines, this doesn't matter a great deal
  20.      for most computations, but on those without floating point hardware, it
  21.      can make a big difference.
  22.  
  23.      Note that this affects the operations, not the numbers.  If you run this
  24.      code
  25.  
  26.          use integer;
  27.          $x = 1.5;
  28.          $y = $x + 1;
  29.          $z = -1.5;
  30.  
  31.      you'll be left with $x == 1.5, $y == 2 and $z == -1.  The $z case happens
  32.      because unary - counts as an operation.
  33.  
  34.      See the section on _P_r_a_g_m_a_t_i_c _M_o_d_u_l_e_s in the _p_e_r_l_m_o_d manpage.
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.