hm, sounds like your Int8's from bombfatal are overflowing. Int8 can only be between -127 and 127. And if you do calculation with it, it stays as Int8, so even 12 * 12 will overflow the datatype...
If you write Int16 = Int8 * Int8 the compiler will probably use 16 bit calculation -> that's why it works then.
So better you use 16 bit for your bombfatal or explicit cast your result to 16 bit:

((Int16) bombfatal*bombfatal)

Henk

Nemanja Bondzulic wrote (some more text as):
Int16 DiffX, DiffY;
Int8 bombfatal;

     if ( ( (DiffX*DiffX + DiffY*DiffY) <= (bombfatal*bombfatal) ) ) {
But  when  I switch on Level 4 optimizations, program never gets into
the  part  which  should  be  executed  when IF statement is true. It
is always false and the code inside the brackets is never executed.

But, if I write this code, like:

Int16 DiffX, DiffY;
Int8 bombfatal;
Int16 a,b;

      a = DiffX*DiffX + DiffY*DiffY;
      b = bombfatal*bombfatal;
      if ( a <= b ) {
it works with Level 4 optimizations!!!

Is this compilers error, or I wrote something wrong here???

--
-------------------------------------------------------------------------
[EMAIL PROTECTED]                                       www.metaviewsoft.de

<A HREF="http://www.handango.com/PlatformTopSoftware.jsp?authorId=95946";>
<IMG SRC="http://user.cs.tu-berlin.de/~jonash/werbung_palmos.jpg";></A>
-------------------------------------------------------------------------


--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to