diff options
Diffstat (limited to 'doc/string/sum.rdoc')
| -rw-r--r-- | doc/string/sum.rdoc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/string/sum.rdoc b/doc/string/sum.rdoc new file mode 100644 index 0000000000..22045e5f4d --- /dev/null +++ b/doc/string/sum.rdoc @@ -0,0 +1,12 @@ +Returns a basic +n+-bit {checksum}[https://en.wikipedia.org/wiki/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 # => 2582 + +This is not a particularly strong checksum. + +Related: see {Querying}[rdoc-ref:String@Querying]. |
