From f9a40a31dbce76e3b9e838504063f08c23dcb4cd Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Thu, 4 Oct 2018 20:07:10 +0000 Subject: [PATCH] Updated and mostly synchronized comment for BitBuffer.appendBits(), in all languages except C. --- cpp/BitBuffer.hpp | 4 ++-- java/io/nayuki/qrcodegen/BitBuffer.java | 4 ++-- javascript/qrcodegen.js | 4 ++-- python/qrcodegen.py | 2 +- rust/src/lib.rs | 2 +- typescript/qrcodegen.ts | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cpp/BitBuffer.hpp b/cpp/BitBuffer.hpp index 436773b..cd31bb4 100644 --- a/cpp/BitBuffer.hpp +++ b/cpp/BitBuffer.hpp @@ -48,8 +48,8 @@ class BitBuffer final : public std::vector { public: std::vector getBytes() const; - // Appends the given number of low bits of the given value - // to this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len. + // Appends the given number of low bits of the given value to + // this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len. public: void appendBits(std::uint32_t val, int len); }; diff --git a/java/io/nayuki/qrcodegen/BitBuffer.java b/java/io/nayuki/qrcodegen/BitBuffer.java index 722a07f..67c4d46 100644 --- a/java/io/nayuki/qrcodegen/BitBuffer.java +++ b/java/io/nayuki/qrcodegen/BitBuffer.java @@ -93,8 +93,8 @@ public final class BitBuffer implements Cloneable { /** - * Appends the specified number of low bits of the specified value - * to this sequence. Requires 0 ≤ val < 2len. + * Appends the specified number of low bits of the specified value to this + * sequence. Requires 0 ≤ len ≤ 31 and 0 ≤ val < 2len. * @param val the value to append * @param len the number of low bits in the value to take * @throws IllegalArgumentException if the value or number of bits is out of range diff --git a/javascript/qrcodegen.js b/javascript/qrcodegen.js index bb556e3..c1459c5 100644 --- a/javascript/qrcodegen.js +++ b/javascript/qrcodegen.js @@ -970,8 +970,8 @@ var qrcodegen = new function() { return result; }; - // Appends the given number of low bits of the given value - // to this sequence. Requires 0 <= val < 2^len. + // Appends the given number of low bits of the given value to + // this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len. this.appendBits = function(val, len) { if (len < 0 || len > 31 || val >>> len != 0) throw "Value out of range"; diff --git a/python/qrcodegen.py b/python/qrcodegen.py index 223e8d0..d2ca629 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -826,7 +826,7 @@ class _BitBuffer(list): def append_bits(self, val, n): """Appends the given number of low bits of the given value - to this sequence. Requires 0 <= val < 2^n.""" + to this sequence. Requires n >= 0 and 0 <= val < 2^n.""" if n < 0 or val >> n != 0: raise ValueError("Value out of range") self.extend(((val >> i) & 1) for i in reversed(range(n))) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 93de6c5..90a0ecb 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1069,7 +1069,7 @@ pub struct BitBuffer(pub Vec); impl BitBuffer { // Appends the given number of low bits of the given value - // to this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len. + // to this sequence. Requires len <= 31 and 0 <= val < 2^len. pub fn append_bits(&mut self, val: u32, len: u8) { assert!(len <= 31 && (val >> len) == 0, "Value out of range"); self.0.extend((0 .. len as i32).rev().map(|i| get_bit(val, i))); // Append bit by bit diff --git a/typescript/qrcodegen.ts b/typescript/qrcodegen.ts index cb5d71d..00c6da5 100644 --- a/typescript/qrcodegen.ts +++ b/typescript/qrcodegen.ts @@ -901,8 +901,8 @@ namespace qrcodegen { } - // Appends the given number of low bits of the given - // value to this sequence. Requires 0 <= val < 2^len. + // Appends the given number of low bits of the given value to + // this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len. public appendBits(val: int, len: int): void { if (len < 0 || len > 31 || val >>> len != 0) throw "Value out of range";