compsci-number-system.html
            
                
                    
                        
                        * created: 2025-06-15T19:00
                        
                         
                        * modified: 2025-10-14T14:34
                        
                        
                    
                
                title
                Number Systems
                description
                A number system is a writing system for expressing numbers using a consistent set of symbols and rules for their arrangement. It defines how numbers are represented and how calculations are performed.
                
                related notes
                
                
             
            Representing raw data
In computer science, number systems are crucial for representing and processing data in digital systems. Different number systems are used depending on the context.
The most relevant of which would be Binary, Hexadecimal and Decimal.
Converting from one to another
There are two main steps we can use to easily convert from one number system to any other number system.
Converting to decimal
The following formula can be used to convert to base 10; b being the base of the number:
w(z) = \sum_{i=0}^{n-1}z_{i} \cdot b^{i}
Example: 1010 0010_{2} = 1 \cdot 2^7 + 0 \cdot 2^6 + 1 \cdot 2^5 + 0 \cdot 2^4 + 0 \cdot 2^3 + 0 \cdot 2^2 + 1 \cdot 2^1 + 0 \cdot 2^0 = 164
Division method
Just perform the euclidean algorithm on a decimal number and read the rest from bottom to top:
Example:
\begin{align}
164 \div 7 = 23 \; | \; r: 3 \\
23 \div 7 = 3 \; | \; r: 2 \\
3 \div 7 = 0 \; | \; r: 3 \\
\\
323
\end{align}
IEEE 754
Single Precision: 1 bit sign, 8 bit exponent (-127); 23 bit mantissa.
\begin{align}
x & = v \cdot m \cdot b^e \\
\\
v & = \text{sign} \\
m & = \text{mantisse} \\
b & = \text{base} \\
e & = \text{exponent} \\
\end{align}
TODO! This should be a separat note: