View previous topic :: View next topic |
Author |
Message |
Guest
|
exponential operation |
Posted: Fri Apr 30, 2004 2:54 am |
|
|
Hi,
The equation 2^(x-1) is exponential form... Is der a way that I can express this using bit shifting operators.
Or any other suggestions..
Thnx |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Fri Apr 30, 2004 3:04 am |
|
|
As long as x>1, the following should do the job:
result=2<<(x-2); |
|
|
Guest
|
|
Posted: Fri Apr 30, 2004 3:09 am |
|
|
Haplo wrote: | As long as x>1, the following should do the job:
result=2<<(x-2); |
Is der another way if I'm going to start my x = 1.
thnx |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Fri Apr 30, 2004 3:13 am |
|
|
Try
result=1<<(x-1);
This should work for x=1 as well. |
|
|
Guest
|
|
Posted: Fri Apr 30, 2004 3:18 am |
|
|
Haplo wrote: | Try
result=1<<(x-1);
This should work for x=1 as well. |
Thanx |
|
|
|