[formatter] better way to determine whether scientific notation should be used