일반적으로 int -> string 변환이랑 string -> int 변환 중에 뭐가 더 빠름?


첨에 생각한 건 컴퓨터는 숫자에 강하니 당연히 int -> string이 빠를 줄 알았는데

string -> int가 훨씬 빠르데?


다시 생각해보니 string -> int는 그냥 메모리 접근 후에 아스키 코드만 숫자로 바꾸면 돼서 덧셈이랑 곱셈만 하면 되는데

int -> string은 자릿수를 옮겨야 하니까 나눗셈이 필요해져서 더 느려지는 거 같기도 하고


테스트는 대충 10만자리 숫자를 int -> string 변환한 거랑 string -> int로 변환한 걸 시간 비교함

찾아본니까 자바도 string -> int가 더 빠르더라고

[](https://stackoverflow.com/questions/6844484/which-is-faster-int-to-string-or-string-to-int)