From 7ac82c23d07f2b94bc6368fc426934686b76a10e Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Thu, 18 Nov 2021 10:09:57 +0200 Subject: [PATCH 1/8] Improved description for task 8. --- .../s0008_string_to_integer_atoi/readme.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md index 16800af6c..242e03b1b 100644 --- a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md +++ b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md @@ -10,7 +10,7 @@ The algorithm for `myAtoi(string s)` is as follows: 2. Check if the next character (if not already at the end of the string) is `'-'` or `'+'`. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present. 3. Read in next the characters until the next non-digit character or the end of the input is reached. The rest of the string is ignored. 4. Convert these digits into an integer (i.e. `"123" -> 123`, `"0032" -> 32`). If no digits were read, then the integer is `0`. Change the sign as necessary (from step 2). -5. If the integer is out of the 32-bit signed integer range `[-231, 231 - 1]`, then clamp the integer so that it remains in the range. Specifically, integers less than `-231` should be clamped to `-231`, and integers greater than `231 - 1` should be clamped to `231 - 1`. +5. If the integer is out of the 32-bit signed integer range `[-231, 231 - 1]`, then clamp the integer so that it remains in the range. Specifically, integers less than -231 should be clamped to -231, and integers greater than 231 - 1 should be clamped to 231 - 1. 6. Return the integer as the final result. **Note:** @@ -24,7 +24,7 @@ The algorithm for `myAtoi(string s)` is as follows: **Output:** 42 -**Explanation:** The underlined characters are what is read in, the caret is the current reader position. Step 1: "42" (no characters read because there is no leading whitespace) ^ Step 2: "42" (no characters read because there is neither a '-' nor '+') ^ Step 3: "42" ("42" is read in) ^ The parsed integer is 42. Since 42 is in the range \[-231, 231 - 1\], the final result is 42. +**Explanation:** The underlined characters are what is read in, the caret is the current reader position. Step 1: "42" (no characters read because there is no leading whitespace) ^ Step 2: "42" (no characters read because there is neither a '-' nor '+') ^ Step 3: "42" ("42" is read in) ^ The parsed integer is 42. Since 42 is in the range \[-231, 231 - 1\], the final result is 42. **Example 2:** @@ -32,7 +32,7 @@ The algorithm for `myAtoi(string s)` is as follows: **Output:** -42 -**Explanation:** Step 1: " \-42" (leading whitespace is read and ignored) ^ Step 2: " \-42" ('-' is read, so the result should be negative) ^ Step 3: " -42" ("42" is read in) ^ The parsed integer is -42. Since -42 is in the range \[-231, 231 - 1\], the final result is -42. +**Explanation:** Step 1: " \-42" (leading whitespace is read and ignored) ^ Step 2: " \-42" ('-' is read, so the result should be negative) ^ Step 3: " -42" ("42" is read in) ^ The parsed integer is -42. Since -42 is in the range \[-231, 231 - 1\], the final result is -42. **Example 3:** @@ -40,7 +40,7 @@ The algorithm for `myAtoi(string s)` is as follows: **Output:** 4193 -**Explanation:** Step 1: "4193 with words" (no characters read because there is no leading whitespace) ^ Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+') ^ Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit) ^ The parsed integer is 4193. Since 4193 is in the range \[-231, 231 - 1\], the final result is 4193. +**Explanation:** Step 1: "4193 with words" (no characters read because there is no leading whitespace) ^ Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+') ^ Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit) ^ The parsed integer is 4193. Since 4193 is in the range \[-231, 231 - 1\], the final result is 4193. **Example 4:** @@ -48,7 +48,7 @@ The algorithm for `myAtoi(string s)` is as follows: **Output:** 0 -**Explanation:** Step 1: "words and 987" (no characters read because there is no leading whitespace) ^ Step 2: "words and 987" (no characters read because there is neither a '-' nor '+') ^ Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w') ^ The parsed integer is 0 because no digits were read. Since 0 is in the range \[-231, 231 - 1\], the final result is 0. +**Explanation:** Step 1: "words and 987" (no characters read because there is no leading whitespace) ^ Step 2: "words and 987" (no characters read because there is neither a '-' nor '+') ^ Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w') ^ The parsed integer is 0 because no digits were read. Since 0 is in the range \[-231, 231 - 1\], the final result is 0. **Example 5:** @@ -56,7 +56,7 @@ The algorithm for `myAtoi(string s)` is as follows: **Output:** -2147483648 -**Explanation:** Step 1: "-91283472332" (no characters read because there is no leading whitespace) ^ Step 2: "\-91283472332" ('-' is read, so the result should be negative) ^ Step 3: "-91283472332" ("91283472332" is read in) ^ The parsed integer is -91283472332. Since -91283472332 is less than the lower bound of the range \[-231, 231 - 1\], the final result is clamped to -231 = -2147483648. +**Explanation:** Step 1: "-91283472332" (no characters read because there is no leading whitespace) ^ Step 2: "\-91283472332" ('-' is read, so the result should be negative) ^ Step 3: "-91283472332" ("91283472332" is read in) ^ The parsed integer is -91283472332. Since -91283472332 is less than the lower bound of the range \[-231, 231 - 1\], the final result is clamped to -231 = -2147483648. **Constraints:** From 4cf271af75a9e248065e8d19e8ff6e3bb8c69f59 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Thu, 18 Nov 2021 10:11:36 +0200 Subject: [PATCH 2/8] Fixed code block. --- src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md index 242e03b1b..d874a72dc 100644 --- a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md +++ b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md @@ -10,7 +10,7 @@ The algorithm for `myAtoi(string s)` is as follows: 2. Check if the next character (if not already at the end of the string) is `'-'` or `'+'`. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present. 3. Read in next the characters until the next non-digit character or the end of the input is reached. The rest of the string is ignored. 4. Convert these digits into an integer (i.e. `"123" -> 123`, `"0032" -> 32`). If no digits were read, then the integer is `0`. Change the sign as necessary (from step 2). -5. If the integer is out of the 32-bit signed integer range `[-231, 231 - 1]`, then clamp the integer so that it remains in the range. Specifically, integers less than -231 should be clamped to -231, and integers greater than 231 - 1 should be clamped to 231 - 1. +5. If the integer is out of the 32-bit signed integer range [-231, 231 - 1], then clamp the integer so that it remains in the range. Specifically, integers less than -231 should be clamped to -231, and integers greater than 231 - 1 should be clamped to 231 - 1. 6. Return the integer as the final result. **Note:** From 82d08782a467d88a01359aac744f0df780405a8e Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Thu, 18 Nov 2021 10:18:39 +0200 Subject: [PATCH 3/8] Improved description. --- .../s0008_string_to_integer_atoi/readme.md | 88 +++++++++++++++++-- 1 file changed, 83 insertions(+), 5 deletions(-) diff --git a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md index d874a72dc..7ebd639b4 100644 --- a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md +++ b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md @@ -24,7 +24,21 @@ The algorithm for `myAtoi(string s)` is as follows: **Output:** 42 -**Explanation:** The underlined characters are what is read in, the caret is the current reader position. Step 1: "42" (no characters read because there is no leading whitespace) ^ Step 2: "42" (no characters read because there is neither a '-' nor '+') ^ Step 3: "42" ("42" is read in) ^ The parsed integer is 42. Since 42 is in the range \[-231, 231 - 1\], the final result is 42. +**Explanation:** The underlined characters are what is read in, the caret is the current reader position. + +Step 1: "42" (no characters read because there is no leading whitespace) + + ^ + +Step 2: "42" (no characters read because there is neither a '-' nor '+') + + ^ + +Step 3: "42" ("42" is read in) + + ^ + +The parsed integer is 42. Since 42 is in the range \[-231, 231 - 1\], the final result is 42. **Example 2:** @@ -32,7 +46,23 @@ The algorithm for `myAtoi(string s)` is as follows: **Output:** -42 -**Explanation:** Step 1: " \-42" (leading whitespace is read and ignored) ^ Step 2: " \-42" ('-' is read, so the result should be negative) ^ Step 3: " -42" ("42" is read in) ^ The parsed integer is -42. Since -42 is in the range \[-231, 231 - 1\], the final result is -42. +**Explanation:** + +Step 1: " \-42" (leading whitespace is read and ignored) + + ^ + +Step 2: " \-42" ('-' is read, so the result should be negative) + + ^ + +Step 3: " -42" ("42" is read in) + + ^ + +The parsed integer is -42. + +Since -42 is in the range \[-231, 231 - 1\], the final result is -42. **Example 3:** @@ -40,7 +70,23 @@ The algorithm for `myAtoi(string s)` is as follows: **Output:** 4193 -**Explanation:** Step 1: "4193 with words" (no characters read because there is no leading whitespace) ^ Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+') ^ Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit) ^ The parsed integer is 4193. Since 4193 is in the range \[-231, 231 - 1\], the final result is 4193. +**Explanation:** + +Step 1: "4193 with words" (no characters read because there is no leading whitespace) + + ^ + +Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+') + + ^ + +Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit) + + ^ + +The parsed integer is 4193. + +Since 4193 is in the range \[-231, 231 - 1\], the final result is 4193. **Example 4:** @@ -48,7 +94,23 @@ The algorithm for `myAtoi(string s)` is as follows: **Output:** 0 -**Explanation:** Step 1: "words and 987" (no characters read because there is no leading whitespace) ^ Step 2: "words and 987" (no characters read because there is neither a '-' nor '+') ^ Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w') ^ The parsed integer is 0 because no digits were read. Since 0 is in the range \[-231, 231 - 1\], the final result is 0. +**Explanation:** + +Step 1: "words and 987" (no characters read because there is no leading whitespace) + + ^ + +Step 2: "words and 987" (no characters read because there is neither a '-' nor '+') + + ^ + +Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w') + + ^ + +The parsed integer is 0 because no digits were read. + +Since 0 is in the range \[-231, 231 - 1\], the final result is 0. **Example 5:** @@ -56,7 +118,23 @@ The algorithm for `myAtoi(string s)` is as follows: **Output:** -2147483648 -**Explanation:** Step 1: "-91283472332" (no characters read because there is no leading whitespace) ^ Step 2: "\-91283472332" ('-' is read, so the result should be negative) ^ Step 3: "-91283472332" ("91283472332" is read in) ^ The parsed integer is -91283472332. Since -91283472332 is less than the lower bound of the range \[-231, 231 - 1\], the final result is clamped to -231 = -2147483648. +**Explanation:** + +Step 1: "-91283472332" (no characters read because there is no leading whitespace) + + ^ + +Step 2: "\-91283472332" ('-' is read, so the result should be negative) + + ^ + +Step 3: "-91283472332" ("91283472332" is read in) + + ^ + +The parsed integer is -91283472332. + +Since -91283472332 is less than the lower bound of the range \[-231, 231 - 1\], the final result is clamped to -231 = -2147483648. **Constraints:** From eff17045d058e94d67ccc370549b22bd5c562e35 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Thu, 18 Nov 2021 10:24:11 +0200 Subject: [PATCH 4/8] Updated description. --- .../s0008_string_to_integer_atoi/readme.md | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md index 7ebd639b4..c34c79cb7 100644 --- a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md +++ b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md @@ -26,19 +26,19 @@ The algorithm for `myAtoi(string s)` is as follows: **Explanation:** The underlined characters are what is read in, the caret is the current reader position. -Step 1: "42" (no characters read because there is no leading whitespace) + Step 1: "42" (no characters read because there is no leading whitespace) - ^ + ^ -Step 2: "42" (no characters read because there is neither a '-' nor '+') + Step 2: "42" (no characters read because there is neither a '-' nor '+') - ^ + ^ -Step 3: "42" ("42" is read in) + Step 3: "42" ("42" is read in) - ^ + ^ -The parsed integer is 42. Since 42 is in the range \[-231, 231 - 1\], the final result is 42. + The parsed integer is 42. Since 42 is in the range \[-231, 231 - 1\], the final result is 42. **Example 2:** @@ -48,21 +48,21 @@ The parsed integer is 42. Since 42 is in the range \[-231, 23131, 231 - 1\], the final result is -42. + Since -42 is in the range \[-231, 231 - 1\], the final result is -42. **Example 3:** @@ -72,21 +72,21 @@ Since -42 is in the range \[-231, 231 - 1\], the final res **Explanation:** -Step 1: "4193 with words" (no characters read because there is no leading whitespace) + Step 1: "4193 with words" (no characters read because there is no leading whitespace) - ^ + ^ -Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+') + Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+') - ^ + ^ -Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit) + Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit) - ^ + ^ -The parsed integer is 4193. + The parsed integer is 4193. -Since 4193 is in the range \[-231, 231 - 1\], the final result is 4193. + Since 4193 is in the range \[-231, 231 - 1\], the final result is 4193. **Example 4:** @@ -96,21 +96,21 @@ Since 4193 is in the range \[-231, 231 - 1\], the final re **Explanation:** -Step 1: "words and 987" (no characters read because there is no leading whitespace) + Step 1: "words and 987" (no characters read because there is no leading whitespace) - ^ + ^ -Step 2: "words and 987" (no characters read because there is neither a '-' nor '+') + Step 2: "words and 987" (no characters read because there is neither a '-' nor '+') - ^ + ^ -Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w') + Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w') - ^ + ^ -The parsed integer is 0 because no digits were read. + The parsed integer is 0 because no digits were read. -Since 0 is in the range \[-231, 231 - 1\], the final result is 0. + Since 0 is in the range \[-231, 231 - 1\], the final result is 0. **Example 5:** @@ -120,21 +120,21 @@ Since 0 is in the range \[-231, 231 - 1\], the final resul **Explanation:** -Step 1: "-91283472332" (no characters read because there is no leading whitespace) + Step 1: "-91283472332" (no characters read because there is no leading whitespace) - ^ + ^ -Step 2: "\-91283472332" ('-' is read, so the result should be negative) + Step 2: "\-91283472332" ('-' is read, so the result should be negative) - ^ + ^ -Step 3: "-91283472332" ("91283472332" is read in) + Step 3: "-91283472332" ("91283472332" is read in) - ^ + ^ -The parsed integer is -91283472332. + The parsed integer is -91283472332. -Since -91283472332 is less than the lower bound of the range \[-231, 231 - 1\], the final result is clamped to -231 = -2147483648. + Since -91283472332 is less than the lower bound of the range \[-231, 231 - 1\], the final result is clamped to -231 = -2147483648. **Constraints:** From 77866466d23492915cfbbb008c4a82c5da76ce45 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Thu, 18 Nov 2021 10:32:24 +0200 Subject: [PATCH 5/8] Updated description. --- .../s0008_string_to_integer_atoi/readme.md | 39 +++---------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md index c34c79cb7..43f5bcaa9 100644 --- a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md +++ b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md @@ -27,18 +27,13 @@ The algorithm for `myAtoi(string s)` is as follows: **Explanation:** The underlined characters are what is read in, the caret is the current reader position. Step 1: "42" (no characters read because there is no leading whitespace) - ^ - Step 2: "42" (no characters read because there is neither a '-' nor '+') - ^ - Step 3: "42" ("42" is read in) - ^ - The parsed integer is 42. Since 42 is in the range \[-231, 231 - 1\], the final result is 42. +The parsed integer is 42. Since 42 is in the range \[-231, 231 - 1\], the final result is 42. **Example 2:** @@ -49,20 +44,14 @@ The algorithm for `myAtoi(string s)` is as follows: **Explanation:** Step 1: " \-42" (leading whitespace is read and ignored) - ^ - Step 2: " \-42" ('-' is read, so the result should be negative) - ^ - Step 3: " -42" ("42" is read in) - ^ - The parsed integer is -42. - Since -42 is in the range \[-231, 231 - 1\], the final result is -42. +Since -42 is in the range \[-231, 231 - 1\], the final result is -42. **Example 3:** @@ -73,20 +62,14 @@ The algorithm for `myAtoi(string s)` is as follows: **Explanation:** Step 1: "4193 with words" (no characters read because there is no leading whitespace) - ^ - Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+') - ^ - Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit) - ^ - The parsed integer is 4193. - Since 4193 is in the range \[-231, 231 - 1\], the final result is 4193. +Since 4193 is in the range \[-231, 231 - 1\], the final result is 4193. **Example 4:** @@ -97,20 +80,14 @@ The algorithm for `myAtoi(string s)` is as follows: **Explanation:** Step 1: "words and 987" (no characters read because there is no leading whitespace) - ^ - Step 2: "words and 987" (no characters read because there is neither a '-' nor '+') - ^ - Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w') - ^ - The parsed integer is 0 because no digits were read. - Since 0 is in the range \[-231, 231 - 1\], the final result is 0. +Since 0 is in the range \[-231, 231 - 1\], the final result is 0. **Example 5:** @@ -121,20 +98,14 @@ The algorithm for `myAtoi(string s)` is as follows: **Explanation:** Step 1: "-91283472332" (no characters read because there is no leading whitespace) - ^ - Step 2: "\-91283472332" ('-' is read, so the result should be negative) - ^ - Step 3: "-91283472332" ("91283472332" is read in) - ^ - The parsed integer is -91283472332. - Since -91283472332 is less than the lower bound of the range \[-231, 231 - 1\], the final result is clamped to -231 = -2147483648. +Since -91283472332 is less than the lower bound of the range \[-231, 231 - 1\], the final result is clamped to -231 = -2147483648. **Constraints:** From 879dbaaf6cda871c2eac15e8a4629f71af216e45 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Thu, 18 Nov 2021 10:37:28 +0200 Subject: [PATCH 6/8] Fixed description. --- src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md index 43f5bcaa9..5ebf18b9f 100644 --- a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md +++ b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md @@ -99,7 +99,7 @@ Since 0 is in the range \[-231, 231 - 1\], the final resul Step 1: "-91283472332" (no characters read because there is no leading whitespace) ^ - Step 2: "\-91283472332" ('-' is read, so the result should be negative) + Step 2: "-91283472332" ('-' is read, so the result should be negative) ^ Step 3: "-91283472332" ("91283472332" is read in) ^ From 358ab7f6206b7e151b39fc7b0ce5207202211a93 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Thu, 18 Nov 2021 10:39:21 +0200 Subject: [PATCH 7/8] Fixed description. --- .../java/g0001_0100/s0008_string_to_integer_atoi/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md index 5ebf18b9f..14b146757 100644 --- a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md +++ b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md @@ -43,9 +43,9 @@ The parsed integer is 42. Since 42 is in the range \[-231, 231 Date: Thu, 18 Nov 2021 10:42:02 +0200 Subject: [PATCH 8/8] Fixed description. --- .../g0001_0100/s0008_string_to_integer_atoi/readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md index 14b146757..f8689415a 100644 --- a/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md +++ b/src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md @@ -48,7 +48,7 @@ The parsed integer is 42. Since 42 is in the range \[-231, 23131, 231 - 1\], the final result is -42. @@ -66,7 +66,7 @@ Since -42 is in the range \[-231, 231 - 1\], the final res Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+') ^ Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit) - ^ + ^ The parsed integer is 4193. Since 4193 is in the range \[-231, 231 - 1\], the final result is 4193. @@ -100,9 +100,9 @@ Since 0 is in the range \[-231, 231 - 1\], the final resul Step 1: "-91283472332" (no characters read because there is no leading whitespace) ^ Step 2: "-91283472332" ('-' is read, so the result should be negative) - ^ + ^ Step 3: "-91283472332" ("91283472332" is read in) - ^ + ^ The parsed integer is -91283472332. Since -91283472332 is less than the lower bound of the range \[-231, 231 - 1\], the final result is clamped to -231 = -2147483648.