> For the complete documentation index, see [llms.txt](https://851958789.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://851958789.gitbook.io/notes/0008_string_to_integer_-atoi/slt.md).

# 思路1 遍历字符串

2 ^ 31 - 1 = 2,147,483,647

按照题意，遇到第一个（非正负号 && 非空格 && 非数字）的字符就停止。 检查溢出的思路类似第七题，不过这道题在计算中不带符号，都是正的，所以只用检查正溢出。如果结果是INT\_MIN的话，正溢出的判断也能检查到。

python对溢出的判断可以放在最后来做（Python没有溢出这一说）
