From 5015efa033197e7312c7c97f03515d0292b0c18c Mon Sep 17 00:00:00 2001 From: Isabell Pflug Date: Tue, 18 Apr 2023 20:36:27 +0200 Subject: [PATCH] :construction: made significant progress for homework no. 1, only explanations for 1.1 missing --- assignments/01/01_1.cpp | 1 - assignments/01/01_2.cpp | 28 +++++++++++++++++++++++++++ assignments/01/CMakeLists.txt | 5 ++--- assignments/01/ues1_pflug_isabell.tex | 18 +++++++++++------ 4 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 assignments/01/01_2.cpp diff --git a/assignments/01/01_1.cpp b/assignments/01/01_1.cpp index d04762d..fd1b24e 100644 --- a/assignments/01/01_1.cpp +++ b/assignments/01/01_1.cpp @@ -1,4 +1,3 @@ -#include #include #include diff --git a/assignments/01/01_2.cpp b/assignments/01/01_2.cpp new file mode 100644 index 0000000..ccf5c61 --- /dev/null +++ b/assignments/01/01_2.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +template int type_definitions() +{ + T t_min = std::numeric_limits::min(); + T t_max = std::numeric_limits::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(t_min).to_string() << std::endl; + std::cout << "Max of " << typeid(t_min).name() << ": \t" << std::bitset(t_max).to_string() << "\n" << std::endl; + return 0; +} + +int main() { + type_definitions(); + type_definitions(); + type_definitions(); + type_definitions(); + type_definitions(); + type_definitions(); + type_definitions(); + type_definitions(); + type_definitions(); + type_definitions(); + return 0; +} diff --git a/assignments/01/CMakeLists.txt b/assignments/01/CMakeLists.txt index f7f7c01..2a69864 100644 --- a/assignments/01/CMakeLists.txt +++ b/assignments/01/CMakeLists.txt @@ -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) diff --git a/assignments/01/ues1_pflug_isabell.tex b/assignments/01/ues1_pflug_isabell.tex index e14eb04..bef2287 100644 --- a/assignments/01/ues1_pflug_isabell.tex +++ b/assignments/01/ues1_pflug_isabell.tex @@ -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}