Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

another c++ conversion 2

Status
Not open for further replies.

tvidigal

Programmer
Sep 8, 2003
19
0
0
PT
hi all,

because of some translations i came to this:

k24float = 1.f/(float)(1<<24);

what is the translation meaning of (1<<24)?
 
<< means shift logical left.

so 1 << 24 is binary 1 with 24 zeros after it.

In Delphi this would be written as 1 shl 24

So your code would be written something like
Code:
k24float := 1 / ( 1 shl 24 );

Andrew

 
thanks!!! so much to be understood about!!! lol

could you be gently and tell how can i translate this:

float frac = (phase & 0x00FFFFFF) * k1Div24lowerBits;

(phase & 0x00FFFFFF) is the bugger ;-)

i know i might be odd with so many questions about differences from C++, cause its my first appearance with them ;-)

thanks a lot
 
& is the bitwise AND operator

( phase & 0x00FFFFFF ) means set the 8 high order bits to zero and leave the remaining 24 bits as they are.

In Delphi this would be written as (phase and $00FFFFFF)

So your code would be written something like

frac := (phase and $00FFFFFF) * K1Div24lowerBits;


Andrew
 
Andrew man, thanks a lot really!!

you've been very helpfull!!

regarding the 1st post same thing goes to

phase >> 24 ---> 24 shl phase right ;)

thank you !!!

best whishes

Tiago
 
Hello again Towerbase,

i come once again over a similar issue!
i really hope you can also answer me this!

in c++ i have:
x, y, z are integer
frq, sr are float
and i have
y = x;
x = frq>(sr/2-100.0);
z = (x^y);

being these values integers i don't understand what it means
could you please tell me how can i translate this to delphi!

thank you very much!

Best Regards,

Tiago

 
This is a very odd piece of code. I suspect that you have missed some lines out.

I don't think that Tek-Tips is intended to be a free coding service. If you are really unable to translate this C++ into Delphi then I suggest you hire someone who can.

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top