|
Re: integer division
Quote:
|
Originally Posted by ImmortalAres
the following is part of kevins accelerometer code
Code:
#include "p18f452.h"
#include "accel.h"
unsigned int X_Axis_Total_Period = 2/1000; // x-axis total cycle time (T2 in the data sheet)
unsigned int X_Axis_Pulse_Period = 0; // x-axis amount of time the pulse is high (T1 in the data sheet)
unsigned int Y_Axis_Total_Period = 2/1000; // y-axis total cycle time (T2 in the data sheet)
unsigned int Y_Axis_Pulse_Period = 0; // y-axis amount of time the pulse is high (T1 in the data sheet)
my debugger says it loops in a file called 16 bit integer division leading me to think that it hangs on the 2/1000 definition of t2
any ideas?
|
Integer division: 2/1000 is equal to 0
In fact, 999/1000 = 0 unless your math routine does rounding...
__________________
Mike Betts
Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013
As easy as 355/113...
|