Introduction to Computing Day3
September 2025, Masayuki Ida, Dr. [Link]
Section 6. Data Types
6.1. Elementary data types in various programming languages
6.2. Primitive Data Types in C++, Python, and Java
6.3. Floating Point numbers! That’s tricky
6.4. Complex data types
6.1. Elementary data types in Various Programming Languages
Programming languages like C, C++, Python, Java, … have “elementary data types.” In section 4 and 5 of
this text introduced a schematic view for “variable” and “data type.”
We upgrade our understanding of variables here. First, we include a data type field in the schematic
representation of variables. Variable is a wisdom in a programming language for a place to hold a value,
and you may access the current value by name, change the value stored to a new one etc. Then, each
variable can store value field which conforms to the data type specified in the data type field.
If variable I has “integer” in the data type field, I can only have a value of integer.
Then what SHOULD happen to the following assignment?
I ⇐ 3.5
You may try it. There are several possibilities.
Possibility 1) the assignment is signaled as ERROR at compilation
Possibility 2) the value 3.5 is converted to 3 (or whatever by the rule of the language) and stored to I
Possibility 3) data type of Variable I is set to “floating point” at runtime
(this is not a popular case, but ‘typeless’ language has similar feature)
Most popular language-specification is possibly 1 or 2. It totally depends on the programming language
specification. You must learn the specification!
Task 6-1: Most of the programming languages have specifications of “rounding” for converting floating
point number to integer. “Rounding” is in general how to adjust the number into integer. There are
typically 3 choices.
1
1) Rounding down: Cut. 3.5 should be 3.
2) Rounding to the nearest integer: 3.5 should be 4 (but 3.2 goes to 3)
3) Rounding up: 3.5 should be 4 (and 3.2 goes to 4)
Research the case for C++ and/or Python using LLM/Google and report it.
No need to program it and test.
6.2. Primitive Data Types in C++, Python, and Java
Elementary Data Types are in some context called Primitive Data types. Because, “Elementary” or
“Primitive” originally means the data types which match the data types of hardware instructions can
handle. Here, we understand there is no big difference between ‘Elementary’ and ‘Primitive.’ They may be
mixed in the following descriptions. Rather, try to follow the programming language choices.
Elementary data types in C++ are defined as follows:
1) int: Used to store whole numbers (integers) without decimal points. Its size typically depends on the
system architecture (commonly 2 or 4 bytes).
2) char: Used to store a single character, such as a letter, number, or symbol. It typically occupies 1 byte
and can also store small integer values representing ASCII or other character encodings.
3) float: Used to store single-precision floating-point numbers, which are numbers with decimal points.
It typically occupies 4 bytes and provides about 6-7 decimal digits of precision.
4) double: Used to store double-precision floating-point numbers, offering higher precision than float.
It typically occupies 8 bytes and provides about 15 decimal digits of precision.
5) bool: Used to store Boolean values, which can only be true or false. It typically occupies 1 byte.
6) void: Represents the absence of a type. It is used in contexts such as function return types when a
function does not return any value, or for generic pointers.
7) wchar_t: Used to store wide characters, which are characters that require more storage than a
standard char, particularly for handling extended character sets like Unicode. Its size can vary,
typically 2 or 4 bytes.
Python has different categories for data types. Which is, Numeric types, Boolean type (bool), string type
(str), sequence types (list, tuple, range), set types (set, frozenset), and mapping type (dict).
There are three data types in numeric types; int, float, complex. Python does not have a separate char
type; individual characters are treated as strings of length one.
Java has the following primitive data types:
byte: An 8-bit signed two's complement integer. Range: -128 to 127.
short: A 16-bit signed two's complement integer. Range: -32,768 to 32,767.
int: A 32-bit signed two's complement integer. Range: -2,147,483,648 to 2,147,483,647.
long: A 64-bit signed two's complement integer.
float: A 32-bit single-precision floating-point number.
2
double: A 64-bit double-precision floating-point number.
boolean: Represents a logical value. Can only be true or false. Used for conditional logic and flags.
char: A 16-bit Unicode character. Used to store single characters.
Historically, Python is the latest. You may feel the difference of dominant ‘culture’ when the language was
invented by examining the differences. You may enjoy later. There are more programming languages.
Task 6-2: Explain the difference between float and double in engineering sense. Which is better to use
in general? Merit and demerit of them? Etc.
Task 6-3: Study about “two’s complement” and report it.
6.3. Floating Point numbers! That’s tricky
Most of the scientific computations need floating point data types to hold the values to calculate. You need
to be aware of the tricky definition in the digital computing world, while floating point numbers are
handled in very early stage like in 1960s.
First, floating point number is always approximate value(, unless otherwise the language and the
system has big-float capability which keep the precision of the floating point number as necessary).
Nowadays, floating point numbers are handled using IEEE 754 standard, to represent and store in a
memory. In other words, if the floating point number is represented in the IEEE 754 standard, it can be
portable among different computers. IEEE 754 standard divides the bits into three parts: a sign bit, an
exponent, and a mantissa (or significand). Single-precision (32-bit) floats use 1 bit for the sign, 8 bits for
the exponent, and 23 bits for the mantissa. Double-precision (64-bit) floats have 1 sign bit, 11 exponent
bits, and 52 mantissa bits. Exponent: Represents the magnitude (or scale) of the number. In the IEEE 754
standard, the exponent is stored with a bias, meaning a value is added to the actual exponent to allow for
both positive and negative exponents. For single-precision, the bias is 127, and for double-precision, it's
1023. Mantissa (Significand): Represents the fractional part of the number, with the leading "1" often
implicit (not stored) to maximize precision.
Look into the flowchart.
For most of the programming languages available,
you had better avoid the above.
Firstly, the result of the first box cannot guarantee to be
the value 0.3. Secondly, you should assume the ‘equal’
comparison is defined as the exact equivalence. So, you
had better assume the result of the comparison goes to
calculate f(I).
3
In the following Python code, the result of adding the floating-point values 0.1 and 0.2 is compared
with the floating-point value 0.3, and the message to be output is switched depending on whether the two
are equal. Which message will be displayed?
a = 0.1 + 0.2 Python uses IEEE754 standard for floating-point number
if a == 0.3: representation. So, it is not a Python specific issue.
print('a == 0.3')
Implementations which follow the standard cannot represent
else:
print('a != 0.3') 0.3. The result of 0.1+0.2 would be something like the following,
if we try to show it as a long precision number.
0.3000000000000000044. And 0.3 is actually 0.299999999999989 or such number. Anyway it’s
approximation.
There are several ways to judge two floating-point numbers are close, like isclose(x, y) of Python, for
many programming languages. In this class, we skip the details.
Task 6-4: Let’s have a break time to confirm your understanding of basic mathematics. Matrix product
is a very popular operation performed in genAI internal function. Get the result by hand calculation.
Matrix A Matrix B
| 1 2 3 | | 2 3 4 |
| 2 3 4 | X | 3 4 5 | = ?
| 3 4 5 | | 4 5 6 |
6.4. Complex data types
In general, the following data types are prepared in programming languages:
String, Vector, Array, Structure, and Object.
Some programming languages treat String as primitive data types. Some define string as a vector of
characters. There are many differences on handling multibyte characters among languages, tools, and
systems such as databases. As a good engineer, you need to know the handling of your favorite language.
Vector is a something like A1, A2, A3, … An, and called totally A. The elements can be identified with
subscripts. Sometimes vector is treated as one-dimensional array.
For most of the high-level languages, array is prepared, with up to 3 dimensions. At least you can think
of two-dimensional arrays.
Structure and object are highly advanced concepts for
freshmen. To understand basic meaning of structure, you can
imagine the records of a file. A record has multiple fields, and
some fields may have sub fields.
Student Record file contains many student records. The above
is an example of the template for such records. It has three fields and the last field is organized with two
4
sub-fields, current address and home address. Each field can have its value, and by specifying the filed
name in your program you can refer the field just like a variable. With this feature, you can make a group
of information as a single structured data.
For object-oriented programming, you may treat this scheme as an object definition. Then you may
create a concrete record, this operation is called creating instance, and refer each field. Accessing a field
or other operations can invoke some methods related with the object oriented facilities.
Details and further discussions are out of concern for freshmen. And the details are quite varying among
specific object-oriented languages. The mechanism was born in the 1970s for Simla, Smalltalk etc. Then
in the middle of the 1980s Common Lisp, an AI language, employed the detailed mechanisms named CLOS,
Common Lisp Object System. Simultaneously, Bjarne Stroustrup developed C++ and published the
specification in 1983. The most powerful use of Object oriented programming were in the quite advanced
systems programming, only generous can understand. So you had better NOT dig the details, unless
otherwise you are exactly in a critical situation.
5
Section 7. Flowchart is not the only one
7.1. There is a state transition diagram
State transition diagrams have different purposes and capabilities from flow diagrams.
7.2. Case: Recursive Programming Structure with Stack Machines
7.3. Case: Parallel Programming Structure with GPU
7.4. AI Programming with heuristics
7.5. AI Programming with Deep Neural Networks
7.1. There is a state transition diagram
State transition diagrams have different purposes and capabilities from flow diagrams. However, they
share the intention of illustrating processes in your brain or concrete workflows. State transition
diagrams are the starting point to use for various upstream processes in graphical and linguistic
expressions.
In a state transition diagram, circles represent the current state (nodes), and arrows (arcs) connect
them. The actions or decisions at that position are written on the arrow. Multiple arcs containing
decisions may leave the same node, and an arc may return to itself or go to another node.
(In the diagram, “A / B” means “if A then B”)
Sometimes, we can use state transition diagram to sketch your strategy. Let us think about the
following.
You are at lunchtime, and you are about to buy bread at a bakery. This bakery sells lunch sets and
drinks that you would normally want. They also sell the usual desserts and fruits. Sometimes you have
limited time, and sometimes you have plenty of time. Your hunger level varies from time to time.
Sometimes you want to eat quickly by yourself alone, and sometimes you want to look cool with your
friends by choosing some fancy lunch set. Last night, your parents praised you, and you have 500,000
VND in cash in your hand now. You can spend it or keep it. What strategy will you have when you are at
the counter? Let's write it down in a state transition diagram.
6
Task 7-1: Draw a state transition diagram for your lunch selection strategy at a bakery. Note that no two
diagrams drawn by different people are identical.
7.2. Case: Recursive Programming Structure with Stack Machines
“Recursive Programming” is a quite high-level concept to use and is not possible for every programming
language. The purpose of introduction here is to know the places you can extend your expertise more.,
Sometimes, you encounter a situation to cope with “problem solving” which needs hierarchical
procedures whose sub procedures had better be written as same as the parent level structure.
Various popular examples of “recursive” procedure can be found in mathematics. One of them is,
factorial function. Which may be defined as follows.
n! = n <= 1 then 1, else n・(n-1)!
This definition is an example of using itself in the definition of it. Namely, factorial(n) uses factorial(n-1)
to define. This is called “recursive function”.
In some programming languages and system development tools, we can write somewhat like the
following. (this is not a concrete example for specific programming languages)
Define factorial (n:integer)
If n <= 1 then return with 1;
else return with n * factorial(n-1)
There are various cases for searching for a solution giving some status parameters like following.
Define Searching (tree:structure)
If tree is null then global-return with null
If a solution is found then global-return with tree
Else Searching( right-hand-side(tree)) and Searching( left-hand-side(tree))
Programs to solve some puzzles, or some intellectual decision-making sometimes better to define as
recursive programs. But, as the author said at the first, details are left for your further study.
Operations for Stack Machines are like follows: for a + b, push a, push b, add
Recursive programming structure, AI programming and stack machines are good buddy. Many times,
compilers use stack machine architecture for internal decomposing phase.
7.3. Case: Parallel Programming Structure with GPU
Imagine you are going to make a simulation program such as store-front simulation of physical retail shop.
So soon, you find you want to write independent programs which simulate the routine actions for store
personnel and for the typical behavior of visiting customers. With some overall monitoring software, you
can simulate what happens at the store-front.
For computer programming, the series of action needs to define as a single thread and it is almost
impossible to write every combination of real time actions of two or more independent people actions.
Easiest case you can understand is a case of shooting game. Game player’s action is independent and
the behavior of game actors inside are independently moving.
As a result, how we can write parallel operations and pack them into a single software package/system
7
has been a long-time concern of computer system designers and developers.
There are various well-designed provisions that need to be prepared as basic software and hardware. As
you can guess, these are also quite advanced topics, and we will not discuss more here. The rest is yours,
bright boys and girls!
As the last paragraph, the author like to add a short comment on GPU programming. GPU is for Graphics
and is prepared for parallel operations than CPU. So simultaneous works of these independent hardware
can achieve performance improvement greatly. Perhaps many of you know that GPU plays a big role in AI.
Because, GPUs are there when neural network is greatly welcomed and several functions of GPU plays
quite effective support to speed up the works with neural networks. GPU is originally for the acceleration
of graphical drawing providing common functions to do it. Early developers with neural networks
recognized the functions of GPU helps a lot. Most important operation is matrix product calculations and
some related operations. Convolution and parameter calculation requires common operations to be
carried out as graphic image drawing.
7.4. AI Programming with heuristics
What is AI Programming for you? In other words, what is your definition of “Artificial Intelligence?”
Before talking about AI, the author likes to introduce the conceptual meaning of “heuristics”.
By asking Google, the following is the response as of July 23, 2025.
Heuristics are mental shortcuts or rules of thumb that people use to make decisions and solve
problems quickly and efficiently, often without needing all the information. They are strategies that
guide us to a solution by using experience-based techniques, educated guesses, and approximations,
rather than following a rigid, step-by-step approach.
Several keywords in the sentences above are explained as follows
Mental Shortcuts: Heuristics are cognitive strategies that allow us to simplify complex situations and
make decisions with less mental effort.
Rules of Thumb: They are often based on past experiences and can be expressed as general guidelines
or principles.
Efficiency: Heuristics help us make quick decisions in situations where time or information is limited.
Not Always Optimal: While heuristics are useful, they can sometimes lead to biases or errors in
judgment because they are not always the most accurate or rational approach according to Investopedia.
And summarized as follows:
In essence, heuristics are valuable tools for navigating the complexities of everyday life, but it's
important to be aware of their potential limitations.
In the context of artificial intelligence and machine learning, a heuristic is a strategy or method that guides
the search for solutions in a more efficient way than exhaustive search methods, by making educated
guesses or applying practical rules of thumb.
Artificial Intelligence comes in two major types, heuristic or rule-based, and statistical or evidence-based.
The first boom of AI is mostly with this type of artificial intelligence. The technological subject was called
8
‘expert system,’ centering ‘rule-base systems.’ Annual international conferences were held with more than
10 thousand people filled the big arena. You may obtain the analysis of such days is available in Chapter
3 and 4 of “Narrative History of Artificial Intelligence”, Springer Nature (BN978-981-97-0770-6 by
Masayuki Ida). Most of such software tool were gone, but some exists now like Business Rules
Management System (BRMS) by Oracle, or open source software for rule based system like OPS5.
Next program fragment is an example to give you an image.
If the room light is not lit, then check the light bulb
else check the breaker of the house.
To describe a strategy or to shoot a trouble source, a rule system with hundreds, or thousands, of rules
were created and used. Sometimes, this design may work well with your program for smart behavior.
7.5. AI Programming with Deep Neural Networks
All the Scientific activities were considered as processes always proven and always leading to the same
results. Especially natural science. Natural science is a science mostly understood with physical
phenomena and mathematical formulation. Along with the progress of civilizations go on, more
probabilistic approaches have been chosen for deep natural science and social science formulation. Then
we established the science of Statistics.
From the early days of invention of digital computers, scientists and engineers wondered human
mechanisms of thinking and processing are same as the mechanisms they created. Perhaps different. So,
even for the inventors of digital computers tried to understand the thinking processing mechanisms of
biological existence. First, they focused on our brain and nerve systems. How they work? Can we mimic
them? These dreams created several early papers and books on brain mechanisms and nerve system
mechanisms even in the 1950s. The analysis of chemical mechanisms of nerve systems concluded the
scheme with neurons and neural networks in such days and lead the emergence of research works on
neural networks in the 1980s. The basic estimation of achievable points, which were amazingly mostly
similar as current engineering targets, were dreamt in such days.
Structures for making the information transferring paths within neural networks were gradually
shaped into real, and some reports in the 1980s showed the multiple leveled network of neurons can
handle the recognition capabilities and stream creating which we may say thinking process.
Several bright scientists and engineers enabled the concrete mimicking of these attitude on digital
computers in the late 1990s. That’s the origin of the current Deep Neural Network success. This history
is described in Chapter 5 and 6 of Narrative history of AI.
Totally speaking the computation process for these mechanisms are, we can say, another type of
statistical handling of huge amounts of data. Here the author stops the discussion for your excitement you
get later.
9
Summary of the introduction we studied:
1. Writing “Process” is a key work in Engineering
2. For Computing, programming is a way to write down the target work to execute
3. Fundamental ways to decompose the target work are A) Sequential operations, B) Decision branching,
and C) Iterations
4. There are always a set of tools to use, programmers must understand them very well
5. There are various types of computer usage such as numeric computations, data processing, and more
smart operations
6. Data Types as a total wisdom for provisions to fill the gap between hardware and software
7. Various fields are waiting for your investigation.
Additional Matters.
Amazingly, task 1 (in section, 2.2) level description in natural language would be possible to create a
program by feeding such explanation to GenAI like ChatGPT, if the generative AI you use understands your
purpose and every facility is ready to use.
The right-side figure shows the
generated codes by a local genAI,
Gemma2. It’s the result of asking “Write a
C++ program to get sum of 1 to 50.”
ChatGPT and other cloud based genAI
can handle more complex cases.
Do you think you don’t need to
learn/study programming languages
anymore???
The author believes learning/studying
programming languages and
development skills will be important
work of human beings even Generative AI can generate various realistic program codes. How do you
think?
Task 7-3: List up 3 main reasons why we need to study how to program while recently Generative AI
can generate some programs.
The author may think of the following thoughts: who is going to be responsible for the codes, how you
can guarantee the correctness, creativity of us, nature of technology advancements, how you get money
for your work, why we study for getting skills which may be replaced by robots later, why do we study
engineering, …
Go on enjoying your class!
10