Skip to content

Instantly share code, notes, and snippets.

@hryniuk
Created January 27, 2017 17:50
Show Gist options
  • Save hryniuk/b961b829707015bb512515213906b934 to your computer and use it in GitHub Desktop.
Save hryniuk/b961b829707015bb512515213906b934 to your computer and use it in GitHub Desktop.
Overflow during negation of minimum of int
#include <iostream>
#include <limits>
int main()
{
int a = std::numeric_limits<int>::min();
std::cout << a << "\n";
std::cout << a * -1 << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment