Board index » delphi » Help with a C++ translation...

Help with a C++ translation...

C has some strange rules for type translations.

I believe 2. is a {*word*218} for 2.0.  If you divide by 2 instead of 2.0, the
result will be an integer, hence the dot.

-- Devin

Quote
Josh Spader wrote in message

<35f6d8d4.36855...@netnews2.worldnet.att.net>...
Quote
>Ok, most of this I can figure, but what are the "." (dots) for after
>the 2 and the 1? And why use fmod if the y variable is a 1?

> */
>LONG coefficient(i, q, firlen, fgk, fgg, fsi, up, down, amp)
>int i, firlen, q, up, down;
>double fgk, fgg, fsi, amp;
>{
> return(
>     (int)(0x10000 * amp *
> interpol_func(
>     (fmod(q*down/(double)up,1.) + (firlen-1)/2. - i) /
>fsi,
>     fgk,
>     fgg
> ) / fsi
>     )
> );
>}

>/*

>Any comments appreciated.
>Josh

 

Re:Help with a C++ translation...


The Dots are to insure that the compiler generates a floating point number
not
a binary interger...
   The Fmode with a 1 in it is to mask the values so that you will get 1 if
the
current results of the Division produces a 1 roll over and not a 0.xxxxx?

Josh Spader <Scir...@Cloud.com> wrote in article
<35f6d8d4.36855...@netnews2.worldnet.att.net>...

Quote
> Ok, most of this I can figure, but what are the "." (dots) for after
> the 2 and the 1? And why use fmod if the y variable is a 1?

>  */
> LONG coefficient(i, q, firlen, fgk, fgg, fsi, up, down, amp)
> int i, firlen, q, up, down;
> double fgk, fgg, fsi, amp;
> {
>    return(
>        (int)(0x10000 * amp *
>            interpol_func(
>                (fmod(q*down/(double)up,1.) + (firlen-1)/2. - i) /
> fsi,
>                fgk,
>                fgg
>            ) / fsi
>        )
>    );
> }

> /*

> Any comments appreciated.
> Josh

Other Threads