**Q:**

I was wondering if you could tell me the mathematics behind this script,

how to do it on paper. (i know nothing about programming)

{

short x;

x = ((short) ( key * -1.2456 ) + 1 ) * 65533;

x = ( x / 2 + 7 ) * 3;

x /- 2;

return x * x;

}

I know that 1 returns 100 and 2 returns 144

Thanks,

*NAME-DELETED*

**A:**

I do not know the mathematics behing this small function. I assume that

function starts something like

short f(short key)

the function actually multiplies the key by the value -1.2456, then

increments the result by one and multiplies it by 65533. Then in the next

line divides this value by two, adds seven and multiplies the result by

three. Finally the program returns the square of this result.

The line

x /-2;

does nothing. There is calculation, but the result is not used and thus

most compilers optimize itout.

Regards,

Peter

[ back to toc ]