🚧 made significant progress for homework no. 1, only explanations for 1.1 missing

main
Isabell Pflug 2 years ago
parent f41f89ca04
commit 5015efa033

@ -1,4 +1,3 @@
#include <stdio.h>
#include <iostream>
#include <typeinfo>

@ -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)

@ -43,6 +43,7 @@
\usepackage{booktabs} % optimised display of tables
\usepackage{tabularx} % more modern display of tables with \toprule,\midrule,\bottomrule
\usepackage{multirow} % allows table cells over multiple rows within a column
\usepackage{tablefootnote} % allows usage of footnotes in tables
%
% misc packages
@ -133,19 +134,24 @@
\begingroup
\setlength{\tabcolsep}{12pt}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{rlcc}
\begin{tabular}{rlll}
\toprule
Zeile & Ausdruck & Wert & Typ \\
\midrule
\verb|1:| & \verb|int a = 5; int b = 2; double c = b;| \qquad \qquad \qquad & -- & -- \\
\verb|2:| & \verb|a * b - - - - - - 12.0f| & & \\
\verb|3:| & \verb|a / b / c| & & \\
\verb|4:| & \verb|a / c / b| & & \\
\verb|5:| & \verb|-1.0f - a * 2E-1 + a / 2| & & \\
\verb|6:| & \verb|1.0 + (a *= (2 / - b - (c += .0E2 )))| & & \\
\verb|2:| & \verb|a * b - - - - - - 12.0f| & 22 & \verb|float| \tablefootnote{32-bit single precision floating-point, IEEE-754} \\
\verb|3:| & \verb|a / b / c| & 1 & \verb|double| \tablefootnote{64-bit double precision floating-point, IEEE-754} \\
\verb|4:| & \verb|a / c / b| & 1.25 & \verb|double| \\
\verb|5:| & \verb|-1.0f - a * 2E-1 + a / 2| & 0 & \verb|double| \\
\verb|6:| & \verb|1.0 + (a *= (2 / - b - (c += .0E2 )))| & -14 & \verb|double| \\
\bottomrule
\end{tabular}
\endgroup
\end{table}
\pagebreak
\Aufgabe
\lstinputlisting[language=C++, breaklines=true]{01_2.cpp}
\end{document}

Loading…
Cancel
Save