home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.misc      General topics about computers not cover      21,759 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 20,981 of 21,759   
   Ben Collver to All   
   On Binary Digits (4/5)   
   01 Apr 25 15:58:47   
   
   [continued from previous message]   
      
               2              010                >  pahtah   
               3              011                V  pod   
               4              100                <  too   
               5              101               A+  tot   
               6              110               >+  dye   
               7              111               V+  tee   
               8          001 000               AO  ooty-pohl   
               9          001 001               AA  ooty-poot   
              10          001 010               AV  ooty-pahtah   
              11          001 011               AV  ooty-pod   
              12          001 100               A<  ooty-too   
              13          001 101              AA+  ooty-tot   
              14          001 110              A>+  ooty-dye   
              15          001 111              AV+  ooty-tee   
              16          010 000               >0  ahtah-pohl   
              17          010 001               >A  ahtah-poot   
              18          010 010               >>  ahtah-pahtah   
              19          010 011               >V  ahtah-pod   
              20          010 100               ><  ahtah-too   
              30          011 110              V>+  oddy-dye   
              40          101 000              A+0  totter-pohl   
              50          110 010              >+>  dye-pahtah   
             100      001,100 100             A,<<  poot one group too-too   
           1,000  001 111,101 000          AV+,A+0  ooty-tee one group   
                                                    totter-pohl   
             ...              ...              ...  ...   
      
   Decimal:         1,000,000   
   Binary, digital: 011,110 100,001 001,000 000   
   Binary, graphic: V,>+<,AA,00   
   Pronounced:      pod three group dye-too ooty-poot ohly-pohl   
                       OR   
                    "Oh, about pod three groups."   
      
   From:   
      
   On Binary Digits And Human Habits by Frederik Pohl (1962)   
      
      
   See also:   
      
   How To Count On Your Fingers by Frederik Pohl (1956)   
      
      
   RFC 1751 S/KEY, Another Human Readable Encoding (1994)   
      
      
   PGP Word List (1995)   
      
      
   * * *   
      
   The number 31337 could be represented as:   
      
       111,101 001,101 001   
      
   And spoken as:   
      
       tee two group totter-poot totter-poot   
      
   Extra credit ideas:   
      
   * Floating point numbers   
   * Equally amusing hand signs for a signed version   
      
   Below is an AWK script to convert between decimal and Pohl code.   
      
       $ cat >pohlcode.awk <<__EOF__   
   # pohlcode.awk version 3 by Ben Collver   
   #   
   # Implement spoken representation of binary numbers described in   
   # On Binary Digits And Human Habits by Frederik Pohl, 1962.   
   #   
   # Dual license: WTFPL and Public Domain   
   #   
   # Pohl encode string from decimal number:   
   #     awk -f pohlcode.awk 31337   
   #   
   # Decode decimal number from Pohl encoded string:   
   #     awk -f pohlcode.awk tee two group totter-poot totter-poot   
      
   # initialize tables used to convert between bases and encodings   
      
   function init(     hl, hu, i) {   
       split("pohl poot pahtah pod too tot dye tee", second, " ")   
       split("ohly ooty ahtah oddy too totter dye teeter", first, " ")   
       split("000 001 010 011 100 101 110 111", trip, " ")   
       split("zero one two three four five six seven eight nine", eng, " ")   
       split("0 1 2 3 4 5 6 7 8 9 A B C D E F", hex, " ")   
       split("0000 0001 0010 0011 0100 0101 0110 0111 " \   
             "1000 1001 1010 1011 1100 1101 1110 1111", bin, " ")   
      
       # bin/dec/hex conversion tables   
       for (i in hex) {   
           hu = hex[i]   
           hl = tolower(hu)   
           h2b[hl] = h2b[hu] = bin[i]   
           h2d[hl] = h2d[hu] = i - 1   
           b2h[bin[i]] = hu   
       }   
      
       # english digit conversion tables   
       for (i in eng) {   
           d2e[i - 1] = eng[i]   
           e2d[eng[i]] = i - 1   
       }   
      
       # Pohl code binary triplet conversion tables   
       for (i in trip) {   
           f2p[trip[i]] = first[i]   
           s2p[trip[i]] = second[i]   
           p2f[first[i]] = trip[i]   
           p2s[second[i]] = trip[i]   
       }   
      
       return   
   }   
      
   function bin2dec(str,    dec, hex) {   
       hex = bin2hex(str)   
       dec = hex2dec(hex)   
       return dec   
   }   
      
   function bin2hex(str,    chunk, n, i, hex, pad, rem) {   
       str = zpad4(str)   
       n = length(str)   
       for (i = 1; i <= n; i += 4) {   
           chunk = zpad4(substr(str, i, 4))   
           hex = hex b2h[chunk]   
       }   
       return hex   
   }   
      
   function bin2pohl(bin,    bbuf, groups, p, parts, retval, val) {   
       groups = int(length(bin) / 6)   
       if (groups > 9) {   
           print "Error: groups out of bounds: " groups   
           exit 1   
       }   
       p = 0   
       bbuf = zpad6(bin)   
       if (length(bbuf) > length(bin)) {   
           val = substr(bbuf, 1, 6)   
           sub(/^000/, "", val)   
           bbuf = substr(bbuf, 7)   
           p++   
           parts[p] = pohlencode(val)   
       }   
       if (groups > 0) {   
           p++   
           parts[p] = d2e[groups] " group"   
       }   
       for (i = 1; i <= groups; i++) {   
           val = substr(bbuf, 1, 6)   
           bbuf = substr(bbuf, 7)   
           p++   
           parts[p] = pohlencode(val)   
       }   
       retval = ""   
       for (i = 1; i <= p; i++) {   
           if (length(retval) == 0) {   
               retval = parts[i]   
           } else {   
               retval = retval " " parts[i]   
      
           }   
       }   
       return retval   
   }   
      
   function dec2bin(dec,    hex, bin) {   
       hex = sprintf("%x\n", dec)   
       bin = hex2bin(hex)   
       return bin   
   }   
      
   function hex2bin(hex,    n, i, bin) {   
       n = length(hex)   
       for (i = 1; i <= n; i++) {   
           bin = bin h2b[substr(hex, i, 1)]   
       }   
       sub(/^0+/, "", bin)   
       if (length(bin) == 0) {   
           bin = "0"   
       }   
       return bin   
   }   
      
   function hex2dec(val,    out, i, n) {   
       if (val ~ /^0x/) {   
           val = substr(val, 3)   
       }   
       n = length(val)   
       for (i = 1; i <= n; i++) {   
           out = (out * 16) + h2d[substr(val, i, 1)]   
       }   
       #return sprintf("%.0f", out)   
       return out   
   }   
      
   function pohl2bin(str,    bbuf, eng, groups, i, prefix, result, wnum, \   
       words)   
   {   
       bbuf = ""   
       groups = 1   
       result = match(str, /.* group /)   
       if (result > 0) {   
           prefix = substr(str, 1, RLENGTH)   
           str = substr(str, RLENGTH + 1)   
           wnum = split(prefix, words, " ")   
           if (wnum == 2) {   
               eng = words[1]   
           } else if (wnum == 3) {   
               eng = words[2]   
               bbuf = pohldecode(words[1])   
               sub(/^0*/, "", bbuf)   
           } else {   
               print "Bad Pohl code prefix: " prefix   
               exit 1   
           }   
           if (eng in e2d) {   
               groups = e2d[eng]   
           } else {   
               print "Invalid number of groups: " eng   
               exit 1   
           }   
       }   
       wnum = split(str, words, " ")   
       if (wnum != groups) {   
           print "Expected " groups " group(s) but got: " wnum   
           exit 1   
       }   
       for (i = 1; i <= wnum ; i++) {   
           bbuf = bbuf pohldecode(words[i])   
       }   
       return bbuf   
   }   
      
   # decode pohl-encoded 6-bit word   
      
   function pohldecode(word,    parts, pnum, retval) {   
       pnum = split(word, parts, "-")   
       if (pnum == 2 && parts[1] in p2f && parts[2] in p2s) {   
           retval = p2f[parts[1]] p2s[parts[2]]   
       } else if (pnum == 1 && parts[1] in p2s) {   
           retval = "000" p2s[parts[1]]   
       } else {   
           print "Invalid pohl code word: " word   
           exit 1   
       }   
       return retval   
   }   
      
   # pohl encode 6-bit word   
      
   function pohlencode(digits,    retval, triplet1, triplet2) {   
       if (length(digits) == 3) {   
           retval = s2p[digits]   
       } else {   
           triplet1 = substr(digits, 1, 3)   
           triplet2 = substr(digits, 4, 6)   
      
   [continued in next message]   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca