Given the variety of applications, it is useful to have algorithms to map in both directions. In many languages, these are better if implemented with iteration rather than recursion. The following C code performs the mappings in both directions, using iteration and bit operations rather than recursion. It assumes a square divided into "n" by "n" cells, for "n" a power of 2, with integer coordinates, with (0,0) in the lower left corner, ("n" − 1, "n" − 1) in the upper right corner, and a distance "d" that starts at 0 in the lower left corner and goes to formula_5 in the lower-right corner. This is different from the animation shown above where the curve starts from upper left corner and terminates at upper right corner.