Thread: Basic Math Help
View Single Post
  #12   Spotlight this post!  
Unread 15-02-2007, 15:18
Cheezmeister Cheezmeister is offline
Registered User
FRC #0871
 
Join Date: Jan 2007
Location: Long Island
Posts: 8
Cheezmeister is an unknown quantity at this point
Re: Basic Math Help

Quote:
Originally Posted by buddy.smith View Post
I stand corrected.

Still, he does not need floating point for this.

(to the OP): Have you ever heard of "fixed point" math? Someone touched on it earlier - if you need .001 precision, then multiply everything by 1000. Keep in mind that at .001 precision, you can measure just one inch with your A/D....

ttyl,

--buddy
Well, floating point is the most direct solution to the precision needed for complex formula. The values he starts with and the values he'll wind up with ought to be ints, but that doesn't mean that everything in the formula can necessarily be rounded.

I mean,
current_height=29.401*(pow((0.0049*((double)Get_An alog_Value(rc_ana_in01)) - 0.0044),-1.0895));
Shouldn't be turned into
current_height=30*(pow((0*((double)Get_Analog_Valu e(rc_ana_in01)) - 0),-1));

You'd always get a divide by zero =P!

However you might be right in that floats/doubles aren't the tools for the job...I can't say; I'm not up on PIC architecture