1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/doc/string/sum.rdoc
Burdette Lamar d52cf1013f
[DOC] Enhanced RDoc for String (#5724)
Treats:

    #scan
    #hex
    #oct
    #crypt
    #ord
    #sum
2022-03-27 14:45:14 -05:00

11 lines
348 B
Text

Returns a basic +n+-bit checksum of the characters in +self+;
the checksum is the sum of the binary value of each byte in +self+,
modulo <tt>2**n - 1</tt>:
'hello'.sum # => 532
'hello'.sum(4) # => 4
'hello'.sum(64) # => 532
'тест'.sum # => 1405
'こんにちは'.sum # => 2582
This is not a particularly strong checksum.