module Addressable::IDNA

def self.punycode_adapt(delta, numpoints, firsttime)

Bias adaptation method
def self.punycode_adapt(delta, numpoints, firsttime)
  delta = firsttime ? delta / PUNYCODE_DAMP : delta >> 1
  # delta >> 1 is a faster way of doing delta / 2
  delta += delta / numpoints
  difference = PUNYCODE_BASE - PUNYCODE_TMIN
  k = 0
  while delta > (difference * PUNYCODE_TMAX) / 2
    delta /= difference
    k += PUNYCODE_BASE
  end
  k + (difference + 1) * delta / (delta + PUNYCODE_SKEW)
end