Programming, Music, Games. Creation.

Posts tagged “number

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++)

printf(“%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,


Binary Numbers – The Easy way to Calculate!

Learning C with Bermuda

The table below explains everything!


0 1 0 0 1 0 0 1
27 26 25 24 23 22 21 20


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

Therefore, the example above will be 01001001 = 26+23+20= 64+8+1 = 73


Simple and easy way to calculate binary numbers :)


OR you can simply use my Binary Swift v2 :P