Skip to content

Instantly share code, notes, and snippets.

@uvegla
Last active September 10, 2017 20:12
Show Gist options
  • Save uvegla/a9cc160b28feaa67f8053bd567bb23d3 to your computer and use it in GitHub Desktop.
Save uvegla/a9cc160b28feaa67f8053bd567bb23d3 to your computer and use it in GitHub Desktop.
Test overflow in std::abs function
#include <iostream>
#include <limits>
#include <cmath>
int main() {
int x = std::numeric_limits<int>::min();;
int a = std::abs(x);
unsigned b = std::abs(x);
std::cout << x << " " << a << " " << b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment