View Single Post
  #4   Spotlight this post!  
Unread 04-02-2008, 19:30
Spider-Man's Avatar
Spider-Man Spider-Man is offline
Curling Rocks
AKA: Adam Jacobson
FRC #0467 (DTB/Shrewsbury Colonials); #0034 (Rocket City Robotics)
Team Role: Mentor
 
Join Date: Dec 2006
Rookie Year: 2000
Location: Shrewsbury, MA USA
Posts: 86
Spider-Man has a spectacular aura aboutSpider-Man has a spectacular aura about
Re: Code spitting out -16256?

The other poster is right about there being casting issues. The sizes of doubles, ints, and chars are quite different, which can cause major problems with ranges.

A good starting point with this kind of code is to cast anything that is not of the same type as the lvalue (variable being assigned). This rule should also include any raw values such as the use of hard-coded in place numbers and #define constant numbers.

As far as the printf statement output, that does not represent the actual value in the least. The double type typically requires '%lf' instead of '%d' in a printf statement, but even then the RC cannot print floating point values, so you need to cast that value to a long and use '%ld' to get a truncated value. You can always multiply the number by some power of 10 to see that number of decimal places.

That should be a good start.
__________________
Student [2000 - 2001] Team 34 Rocket City Robotics
Plays Well With Others
2000 VA - Delphi "Driving Tomorrow's Technology"
2000 CMP - Top 5 Autodesk Visualization
2001 TX - Regional Finalist

Mentor [2004 - 2005][2007 - ????] Team 467 Shrewsbury Colonials (nee Duct Tape Bandits)
We Not Me
2004 LI - DaimlerChrysler Team Spirit
2004 LI - Website Design
2005 MD - Delphi "Driving Tomorrow's Technology"
2007 MA - Johnson & Johnson Sportsmanship
2008 CT - Judges' Award
2008 PA - Judges' Award

2010 MA - Judge's Award[/size][/font]
2012 DC - Chrysler Team Spirit[/size][/font]
2012 DC - Regional Winners[/size][/font]
2013 MAWO - Engineering Inspiration[/size][/font]