Skip to content

Commit

Permalink
Reverse order for values below zero_point
Browse files Browse the repository at this point in the history
  • Loading branch information
DRMacIver committed Jul 12, 2020
1 parent b2ea73c commit 04f3dff
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,19 @@ def rewrite_integer(self, i):
# characters with simple ascii characters, so we rejig this
# bit so that the smallest values are 0, 1, 2, ..., Z.
#
# Imagine that numbers are laid out as xxx0yyyZ...
# Imagine that numbers are laid out as abc0yyyZ...
# this rearranges them so that they are laid out as
# 0yyyZxxx..., which gives a better shrinking order.
# 0yyyZcba..., which gives a better shrinking order.
if i <= self.Z_point:
# We want to rewrite the integers [0, n] inclusive
# to [zero_point, Z_point].
n = self.Z_point - self.zero_point
if i <= n:
i += self.zero_point
else:
# This means we need to rewrite n + 1 to 0
i -= n + 1
# This means we need to rewrite n + 1 to zero_point - 1, and
# sh
i = self.zero_point - (i - n)
assert i < self.zero_point
assert 0 <= i <= self.Z_point
return i
Expand Down

0 comments on commit 04f3dff

Please sign in to comment.