@@ -55,14 +55,21 @@ // Returns an integer from a fibonacci code as specified in the package doc. func (f Numbers) Decode(value uint64) (result uint64) { i := 1 for (value & 3) != 3 { + // Add the fibonacci number for the current bit if it is raised if (value & 1) == 1 { result += f.Nth(i) + + // We know that the next bit cannot be raised by Zeckendorf's theorem + value >>= 2 + i += 2 + continue } + value >>= 1 i++ } result += f.Nth(i) - 1 return }