Henrik Samuelsson’s Reviews > Introduction to Programming with C++ for Engineers > Status Update

Henrik Samuelsson
Henrik Samuelsson is on page 516 of 656
Arithmetic values can have different bases. Humans use base 10 because they come equipped with 10 fingers.

Computers will generally use base 2 due that the fundamental unit in a computer is the bit and this can only have 2 different states, 1 or 0.

A computer combines several bits to handle larger values than 0 and 1. A byte holding 8 bits can store values 0 to 255, or -128 to 127 depending on bit interpretation.
Aug 18, 2023 11:26PM
Introduction to Programming with C++ for Engineers (IEEE Press)

flag

Henrik’s Previous Updates

Henrik Samuelsson
Henrik Samuelsson is on page 597 of 656
Last chapter looks briefly into parallel execution of code in C++.

- Measure performance before refactoring, don't guess, use a profiler
- Must protect shared variables (mutex or similar)
- Many C++ standard algorithms comes with parallel implementation (std::execution::par)
- A good choice for parallel programming in C++ is to use OpenMP
Aug 20, 2023 12:47AM
Introduction to Programming with C++ for Engineers (IEEE Press)


Henrik Samuelsson
Henrik Samuelsson is on page 570 of 656
Real numbers are in computers often represented by floating point numbers. It is important to understand that this is only an approximation and that this introduces limitations:

- There will be rounding errors
- The spacing is not uniform, larger numbers are less exact
- Subtraction of close numbers can lead to severe cancelation errors

Floating point values are rounded to the nearest, ints are truncated towards 0.
Aug 19, 2023 04:36AM
Introduction to Programming with C++ for Engineers (IEEE Press)


Henrik Samuelsson
Henrik Samuelsson is on page 539 of 656
Aug 19, 2023 01:10AM
Introduction to Programming with C++ for Engineers (IEEE Press)


Henrik Samuelsson
Henrik Samuelsson is on page 521 of 656
Integers values can be stored exactly in computers. For example 10 can be represented by the bit combination 0000 1010, meaning 8 + 2 = 10

Fractions might not be able to be stored exactly in computers. Fractions that involves multiples of 2 can be stored exactly if using sufficient numbers of bits. But other fractions will never be exact, regardless of bits used for storage there will still be an rounding error.
Aug 19, 2023 01:03AM
Introduction to Programming with C++ for Engineers (IEEE Press)


Henrik Samuelsson
Henrik Samuelsson is on page 516 of 656
Integer addition in C++ requires storage for the result of adequate size.

Adding unsigned integers that do not fit in the result variables will cause overflow and the result wraps around. The result will be the same as using the modulo operation, likely not the desired result.

Overflow behaviour when adding two signed integers is undefined so this is even worse.

In general arithmetic overflow needs to be avoided.
Aug 19, 2023 12:39AM
Introduction to Programming with C++ for Engineers (IEEE Press)


Henrik Samuelsson
Henrik Samuelsson is on page 509 of 656
Objects are not limited to storing data they are also used for actions, these are referred to as functional objects. Functional objects will implement the overloaded functional operator ().
Aug 18, 2023 10:58PM
Introduction to Programming with C++ for Engineers (IEEE Press)


Henrik Samuelsson
Henrik Samuelsson is on page 489 of 656
The visitor pattern is a software design pattern that separates the algorithm from the object structure.

This separation allows new operations to be added to existing object structures without modifying the structures. It is hence a way to follow the open/closed principle in object-oriented programming and software engineering.

The visitor pattern is used in the book to traverse a tree.
Aug 17, 2023 09:29PM
Introduction to Programming with C++ for Engineers (IEEE Press)


Henrik Samuelsson
Henrik Samuelsson is on page 463 of 656
Aug 16, 2023 09:03PM
Introduction to Programming with C++ for Engineers (IEEE Press)


Henrik Samuelsson
Henrik Samuelsson is on page 452 of 656
There are various clock objects available in C++ to measure time.

std::chrono::system_clock - A clock from the system-wide real time clock, note that this can be adjusted at any time beyond our control.

std::chrono::steady_clock - Another clock that will not be adjusted.

std::chrono::high_resolution_click -The clock with the shortest tick on the given platform.
Aug 16, 2023 09:03PM
Introduction to Programming with C++ for Engineers (IEEE Press)


Henrik Samuelsson
Henrik Samuelsson is on page 452 of 656
Aug 15, 2023 11:29PM
Introduction to Programming with C++ for Engineers (IEEE Press)


No comments have been added yet.