Something new for me
-
How to say
int i = 0
?- We will say
i
get zero.
- We will say
-
Any zero in computer is false and any non-zero value is true.
What is compiler?
- A compiler is an application that can transform source code into machine code.
How computer to represent negative numbers?
There are have three ways to represent negative numbers in binary.
-
Sign bit
-
Example:
-
Pros:
- easy understand
-
Cons:
- It is not suitable for performing addition operations.
-
-
one complement
-
Example:
-
Pros:
- easy understand
-
Cons:
- The result obtained from addition operations is not precisely accurate, but rather a close approximation.
-
-
two complement
-
Example:
-
Pros:
- The result obtained from addition operations is accurate.
-
Cons:
- It is not easily comprehensible
-
What is integer overflow and how?
In short, integer overflow refers to the situation where an integer is too large to be represented using only 32 bits.
For example, if we attempt to represent an integer using only 4 bits, the sum of 9 (1001) and 10 (1010) would be expected to be 19. However, in the binary world, the result would be as follows:
But why does this happen? When adding the first bit 1 + 1, the result is 2, which requires carrying over to another bit. However, since we are only using 4 bits to represent integers, there is no other bit available to handle the carried over digit. As a result, the answer becomes 3 (0011), which is an example of integer overflow.
What is truncation?
Truncation refers to the process of removing a portion of data. For instance, truncating the number 5.678981023 to two decimal places results in the value 5.67
What is floating-point imprecision?
Computers use a system similar to scientific notation to represent very large or very small numbers, and computer storage space is limited. Therefore, the concept of infinite decimals cannot be expressed. When two very small numbers are added together, the result cannot be accurately represented.
For example, 0.3 + 0.3 + 0.3 = 0.9xxxxxxxxx