Question about signed and unsigned ints in c++

What are the largest signed and unsigned ints in c++?
signed: std::intmax_t (usually long long)
unsigned: std::uintmax_t (usually unsigned long long)
http://en.cppreference.com/w/cpp/types/integer

Check it out on the implementation that you are using:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <limits>
#include <cstdint>

int main()
{
    std::cout << std::numeric_limits<std::intmax_t>::min() << " to "
              << std::numeric_limits<std::intmax_t>::max() << '\n'

              << std::numeric_limits<long long>::min() << " to "
              << std::numeric_limits<long long>::max() << '\n'

              << "0 to " << std::numeric_limits<std::uintmax_t>::max() << '\n'
              << "0 to " << std::numeric_limits<unsigned long long>::max() << '\n' ;
}

http://coliru.stacked-crooked.com/a/f270dfea8292e365
Last edited on
Topic archived. No new replies allowed.