[gnome-university] c101: fill in some type information in chapter 2.



commit 1f19a7b3daf4b8de0cd3c17a8def247fefee881e
Author: Christian Hergert <christian hergert me>
Date:   Mon Nov 5 00:22:42 2012 -0800

    c101: fill in some type information in chapter 2.

 c101/tex/chapter2.tex |   41 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/c101/tex/chapter2.tex b/c101/tex/chapter2.tex
index e4c01e9..b95c46b 100644
--- a/c101/tex/chapter2.tex
+++ b/c101/tex/chapter2.tex
@@ -55,7 +55,46 @@ Chapter 2}
 \maketitle
 
 In Chapter 1 we learned the basics of how to write software in C, compile and then execute our program.
-In Chapter 2 we will learn more about types, basic arithmetic, and how to read in text from the command line.
+In Chapter 2 we will learn more about types, comments, basic arithmetic, and how to read in text from the command line.
+
+\section{Types}
+
+TODO
+
+\begin{itemize}
+\item what does the size of a type mean
+\end{itemize}
+
+In the last chapter we learned what an \verb|integer| is.
+The C programming language supports many more types than just \verb|integer|.
+One such type is \verb|float|, short for floating point.
+A \verb|float| can store numbers that contain a decimal point, like \verb|98.6|.
+
+The type \verb|double| is just like \verb|float|, except it can hold much larger numbers!
+A \verb|float| consumes four bytes of memory while a \verb|double| consumes eight.
+The extra space consumed by a \verb|double| allows it to be much more precise in representing numbers with many digits before or after the decimal point.
+
+Another type is \verb|char|, short for character.
+A \verb|char| can store a single character, like the letter \verb|a|, \verb|b|, or \verb|c|.
+
+The type \verb|short| is used to hold integers just like \verb|int|.
+However, it can only hold a subset of them (from -32767 to 32768).
+That might seem not very worth while, until you learn that it only takes half the space of an \verb|integer|!
+
+\begin{figure}
+\centering
+\begin{tabular}{r c l}
+Type & Size & Description \\
+\hline
+char & 1 & \\
+short & 2 & \\
+int & 4 & \\
+float & 4 & \\
+double & 8 & \\
+\end{tabular}
+\caption{Basic types in C}
+\label{fig:types}
+\end{figure}
 
 \section{Comments}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]