You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
982 B
C++
29 lines
982 B
C++
#include <iostream>
|
|
#include <typeinfo>
|
|
#include <limits>
|
|
#include <bitset>
|
|
|
|
template <typename T> int type_definitions()
|
|
{
|
|
T t_min = std::numeric_limits<T>::min();
|
|
T t_max = std::numeric_limits<T>::max();
|
|
std::cout << "Size of " << typeid(t_min).name() << ": \t" << sizeof(T)*8 << std::endl;
|
|
std::cout << "Min of " << typeid(t_min).name() << ": \t" << std::bitset<sizeof(T)*8>(t_min).to_string() << std::endl;
|
|
std::cout << "Max of " << typeid(t_min).name() << ": \t" << std::bitset<sizeof(T)*8>(t_max).to_string() << "\n" << std::endl;
|
|
return 0;
|
|
}
|
|
|
|
int main() {
|
|
type_definitions<char>();
|
|
type_definitions<unsigned char>();
|
|
type_definitions<short int>();
|
|
type_definitions<unsigned short int>();
|
|
type_definitions<int>();
|
|
type_definitions<unsigned int>();
|
|
type_definitions<long int>();
|
|
type_definitions<unsigned long int>();
|
|
type_definitions<long long int>();
|
|
type_definitions<unsigned long long int>();
|
|
return 0;
|
|
}
|