View Single Post
  #6   Spotlight this post!  
Unread 07-02-2004, 19:19
Jeff McCune's Avatar
Jeff McCune Jeff McCune is offline
Alpha Geek
#0677 (The Wirestrippers)
Team Role: Mentor
 
Join Date: Jan 2003
Location: The Ohio State University
Posts: 67
Jeff McCune is on a distinguished road
Send a message via ICQ to Jeff McCune Send a message via AIM to Jeff McCune
Re: Compiler Help Needed

Also, you can completley eliminate floating point from your code.

#define axelWidth 0.725

becomes:

#define AXEL_WIDTH_NUM 29
#define AXEL_WIDTH_DEN 40

Constants that are #defined are usually all caps by convention.

Also, keep in mind that when using integers, order of operations isn't the same as it is in your math class. Well, it is, but the order of operations will affect the result of the equation.
Code:
// Consider:
#define NUM 50
#define DEN 100
int foo = NUM / DEN * joy1_y
int bar = NUM * joy1_y / DEN
foo will ALWAYS be 0. Always. this is becuase NUM divided by DEN in integer math will be 0, and 0 multiplied by anything is zero. bar will contain what you think it should based on the equation.

Basically, stick to integer math, and multiply to the biggest number you can before starting to divide using integers to prevent always multoplying by zero.
__________________
Team 677 - The Wirestrippers - Columbus School for Girls and The Ohio State University
EMAIL: mccune@ling.ohio-state.edu

...And all you touch and all you see
Is all your life will ever be...

Last edited by Jeff McCune : 07-02-2004 at 19:22.