CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

math.h, how fast or slow?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Nikki
Guest







math.h, how fast or slow?
PostPosted: Mon Jun 23, 2003 4:41 pm     Reply with quote

I'm using an 18F452.

Can it be right for math.h to take 11078 instructions to calculate cosine?

Inside "float cos(float x)", the line below costs just 1780 instructions.

quad = (int)(x / PI_DIV_BY_TWO); // quadrant

Is this expected?

It seems to be calculating correct values as I'm using these functions in graphics routines, but it's so sloooww.

Nikki
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515490
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

Re: math.h, how fast or slow?
PostPosted: Mon Jun 23, 2003 5:24 pm     Reply with quote

One way to work around the slowness of the Cos function is to set up a Cosine table in your program and then simply perform a table look-up whenever you need a Cos value.

Ali
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515493
Nikki
Guest







Re: math.h, how fast or slow?
PostPosted: Mon Jun 23, 2003 5:53 pm     Reply with quote

:=One way to work around the slowness of the Cos function is to set up a Cosine table in your program and then simply perform a table look-up whenever you need a Cos value.

Thanks, I'm having a look at the CORDIC algorithm at the moment, though I'll probably go with a table.

Nikki
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515497
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group