Vorzeichenbehafteter Ganzzahlüberlauf: 998765432 * 10 kann nicht im Typ „int“ dargestellt werden ... Was mache ich hier?C++

Programme in C++. Entwicklerforum
Anonymous
 Vorzeichenbehafteter Ganzzahlüberlauf: 998765432 * 10 kann nicht im Typ „int“ dargestellt werden ... Was mache ich hier?

Post by Anonymous »

Code:

Code: Select all

class Solution {
public:
bool isPalindrome(int x) {
int out = 0;
int normal = x;
while(normal > 0){
out *= 10;
out += normal % 10;
normal /= 10;
}

if(out == x){
return true;
} else {
return false;
}
}
};
Fehler:

Code: Select all

Line 7: Char 17: runtime error: signed integer overflow: 998765432 * 10 cannot be represented in type 'int' (solution.cpp)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior prog_joined.cpp:16:17

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post