Sum

sum

ri

 ------------------------------------------------------------- String#sum
      str.sum(n=16)   => integer
 ------------------------------------------------------------------------
      Returns a basic _n_-bit checksum of the characters in _str_, where
      _n_ is the optional  Fixnum  parameter, defaulting to 16. The
      result is simply the sum of the binary value of each character in
      _str_ modulo  2n - 1 . This is not a particularly good checksum.
 

refe

 String#sum
 --- sum([bits=16])
 
     文字列の bits ビットのチェックサムを計算します。
     以下と同じです。
 
         sum = 0
         str.each_byte {|c| sum  = c}
         sum = sum 
		
  • 2006/05/15 12:32:16 inject
  • 2006/05/15 11:49:03 String
  • 2006/05/15 13:01:36 sum