Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   C programming problem... (http://www.chiefdelphi.com/forums/showthread.php?t=24894)

wasabi824 07-02-2004 15:43

C programming problem...
 
hey we're trying to use a simple cosine function call in our code, and we've done the "#include <math.h>" already but we keep getting an error of

"Error - could not find definition of symbol 'cos' in file 'C:\Program Files\MPLAB IDE\default\user_routines.o'. "

when we try to compile. obviously, this is using the MPLAB IDE v6.30... has anyone else successfully used the math functions in their code, or any suggestions on how to fix this?

thanks in advance,
jason

phrontist 07-02-2004 15:45

Re: C programming problem...
 
Quote:

Originally Posted by wasabi824
and we've done the "#include <math.h>"

Where did you get this math.h library? Unless it was specifically written to adhere to the C18 standard, it won't work. :rolleyes:

ShadowKnight 07-02-2004 15:52

Re: C programming problem...
 
You could try making a table lookup. Basically make a table in Excel then copy it into your code. the problem with this is you only have the values you put in the table.

rom float costable[numvalues] = {1, .985, etc., etc, etc...}

Check out this thread: math.h

wasabi824 07-02-2004 15:52

Re: C programming problem...
 
we thought that math.h was part of the default C programming library... but any advice on how to implement/call cosine in MPLAB assuming we can't use math.h?

thanks

KevinB 07-02-2004 23:43

Re: C programming problem...
 
Nope ... there is no sine or cosine for the PIC. The best bet is to make a lookup table and just reference it. I would avoid using floating point variables though and stick to integers. Search CD for "lookup table" and you should be able to find what you need to know. This has been discussed several times.

steven114 08-02-2004 01:04

Re: C programming problem...
 
And, if you do use floating point, use doubles not floats. I had a lot of troubles with roundoff errors until I switched. 100/25 = 3.99 apparently :) Must be Pentium-based... ;)


All times are GMT -5. The time now is 04:00.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi