about two years ago, i was taking a class in uni. our last assignment was to implement huffman coding in c. a classmate needed to find some way to represent the path from the root of the tree to a leaf. typically paths are represented as a sequence of 0s and 1s, to determine whether you need to take the left or right child of the node you're at.
the way he represented the path was with a long long. and so there are 255 possible byte values, and a long long is only 64 bytes long. this seems like a bad idea. but he used the digits of a long long instead, and in his scheme a 1 meant to take the left child and a 2 meant to take the right child of a node. his paths were backwards, so '122' meant right -> right -> left. he traversed the tree by dividing the path by 10, and when his path reached '0', he knew he was at a leaf node.
his code still broke when he was given input with too wide a variety of characters. one of the files the professor used to test our code was moby dick, and it made his program spit out n