You can truncate strings with a printf field-width specifier:
printf
printf(\"%.5s\", \"abcdefgh\"); > abcde
Unfortunately it does no
If you want to truncate from the right you can convert your number to a string and then use the string field width specifier.
"%.3s".format(1234567.toString)