🚧 made significant progress for homework no. 1, only explanations for 1.1 missing
parent
f41f89ca04
commit
5015efa033
@ -0,0 +1,28 @@
|
||||
#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;
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.11.4)
|
||||
project (01)
|
||||
|
||||
file(GLOB SOURCES "*.cpp")
|
||||
|
||||
add_executable(01_1 ${SOURCES})
|
||||
add_executable(01_1 01_1.cpp)
|
||||
add_executable(01_2 01_2.cpp)
|
||||
|
Loading…
Reference in New Issue