Since setInt() is a String method, it can check the current and maximum length fields and prevent appendChar() from failing.
My setInt() main loop is basically
while (len < max) {
...
append next character
if conversion complete
return;
...
}
do Sys.error(19);
--Mark