Csound Csound-dev Csound-tekno Search About

Re: Csound+Math question?

Date1999-03-10 08:07
FromRoger Klaveness
SubjectRe: Csound+Math question?
OOOOOPPPPPPSSSSSS !!!!

Thats the way it goes when you are doing something a little to fast.

How about this 

 2^1 = 2
 2^2 = 2*2 = 4
 2^3 = 2*2*2 = 8
 2^4 = 2*2*2*2 = 16
 2^5 = 2*2*2*2*2 = 32
 2^6 = 2*2*2*2*2*2 = 64
 2^7 = 2*2*2*2*2*2*2 = 128
 2^8 = 2*2*2*2*2*2*2*2 = 256
 2^9 = 2*2*2*2*2*2*2*2*2 = 512
 2^10= 2*2*2*2*2*2*2*2*2*2 = 1024
 2^11= 2*2*2*2*2*2*2*2*2*2*2 = 2048
 2^12= 2*2*2*2*2*2*2*2*2*2*2*2 = 4096
 2^13= 2*2*2*2*2*2*2*2*2*2*2*2*2 = 8192
 2^14= 2*2*2*2*2*2*2*2*2*2*2*2*2*2 = 16384
 2^15= 2*2*2*2*2*2*2*2*2*2*2*2*2*2*2 = 32768
 2^16= 2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2 = 65536

and some more :

2^0 = 1

2^-1 = 1/2 = 0.5
2^-2 = 1/(2*2) = 0.25
2^-3 = 1/(2*2*2) = 0.125
2^-4 = 1/(2*2*2*2) = 0,0625

The importance of this is that computers and other digital systems uses 
a binary numbers system in which every number is represented by a number 
of "bits" which can have a value of 0 or 1.
This is called a number system with a base of 2.
The wordlength is how many bits you are using.
For example with a wordlenght of 3 you count like this

000 = 0
001 = 1
010 = 2
011 = 3
100 = 4
101 = 5
110 = 6
111 = 7

With a wordlenght of 3 you can count 8 numbers
2^3=8

Similar with a wordlenght of 8 you can count 2^8 = 256 numbers
and with a wordlenght of 16 you can count 2^16 = 65536 numbers

Computers usually use wordlenghts of 8,16,32 or 64

Note this wordlenghts are itselfs a power of 2 which 
shortly explained makes it more efficient for the computer 
to store and fetch the numbers

Generally speaking one can say:
- computers really like things that are a power of 2
- people that programs to much assembly or makes digital electronics 
  starts dreaming binary and hexadecimal numbers

Hexadecimal numbers by the way are a numbers system with a base of 16 instead of 
10 which is our normal number system and is called decimal number system

Hex Dec   Bin
0  = 0  = 0000
1  = 1  = 0001
2  = 2  = 0010
3  = 3  = 0011
4  = 4  = 0100
5  = 5  = 0101
6  = 6  = 0110
7  = 7  = 0111
8  = 8  = 1000
9  = 9  = 1001
A  = 10 = 1010
B  = 11 = 1011
C  = 12 = 1100
D  = 13 = 1101
E  = 14 = 1110
F  = 15 = 1111


Roger K

"David O. Baird" wrote:
> 
> Sonicman,
> 
> I though you might want to know that Roger Klaveness's response to your
> question contained a typographical error that resulted in incorrect
> definitions of 2^7, 2^8 and 2^9.  His response should have been:
> 
> 2^1 = 2
> 2^2 = 2*2 = 4
> 2^3 = 2*2*2 = 8
> 2^4 = 2*2*2*2 = 16
> 2^5 = 2*2*2*2*2 = 32
> 2^6= 2*2*2*2*2*2 = 64
> 2^7= 2*2*2*2*2*2*2 = 128
> 2^8= 2*2*2*2*2*2*2*2 = 512
> 2^9= 2*2*2*2*2*2*2*2*2 = 1024
>