Strings, substrings, and the nearest integer function