View Single Post
  #1   Spotlight this post!  
Unread 13-01-2004, 00:40
Larry Barello Larry Barello is offline
http://www.barello.net
#0492 (Titan Robotics Club)
Team Role: Mentor
 
Join Date: Jan 2002
Location: Bellevue, WA
Posts: 85
Larry Barello has a spectacular aura aboutLarry Barello has a spectacular aura about
Whacky C Complier behavior

Beware! The compiler assumes constants are of type "char"

For example, this will generate no errors and give you -12 as the results!

int InitFoo = (100 * 5);

To get the right answer, you need to cast the 100 as an int:

int InitFoo = (int)100 * 5;

Sigh.

P.S. - floating point constants are completely screwed up. Not even casting seems to help.

Last edited by Larry Barello : 13-01-2004 at 00:51.