## How does the computer save Real Numbers?

# How does the computer save real numbers?

Lets look at only 2 bytes. (in reality, the computer uses more than 4 bytes to save real numbers.)

The computer uses the following equation to save real numbers

### Why use this equation?

setting ‘m’ as numbers before ‘.’ and setting ‘e’ as numbers after ‘.’ is inefficient and takes a lot of memory to save real numbers.

However, using the equation, the computer is able to save real numbers efficiently, no matter how complicated they are.

Still, the computer cannot save wide range of real numbers and cannot save them accurately. It simply saves the data closest possible to the value we want to save. This is called float-point error.

### Float-point error

#include <studio.h>

int main(void)

{

int i;

float f=0.0;for(i=0; i<100; i++)

f+=0.1printf(“%f “, f);

return 0;

}

the following is a good example of float error.

Variable f is declared,

until ‘i’ becomes 100, 0.1 is added to ‘f’

since ‘i++’ is used, ‘f’ is added by 0.1 100 times

The output must be 10, however you will see slight difference in the value. For example,

10.00002

## Binary Numbers – The Easy way to Calculate!

The table below explains everything!

0 |
1 |
0 |
0 |
1 |
0 |
0 |
1 |

2^{7} |
2^{6} |
2^{5} |
2^{4} |
2^{3} |
2^{2} |
2^{1} |
2^{0} |

Simply add the 2^{x} when that specific place has ‘1’ instead of ‘0’

Therefore, the example above will be **01001001** = **2 ^{6}+2^{3}+2^{0}**= 64+8+1 =

**73**

Simple and easy way to calculate binary numbers :)

OR you can simply use my Binary Swift v2 :P

## Latest Comments