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

Calculus

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







Calculus
PostPosted: Fri Dec 13, 2002 7:24 am     Reply with quote

Hello...

I have a question about calc.
I wish put in the main program a potencial function y=a*x^b but when I use math.h library with the pow() function the memory code or ROM memory it's used untill 89\%. How can I do the same but useless too memory.

Greating
CPB.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10024
Sherpa Doug
Guest







Re: Calculus
PostPosted: Fri Dec 13, 2002 7:43 am     Reply with quote

:=Hello...
:=
:=I have a question about calc.
:=I wish put in the main program a potencial function y=a*x^b but when I use math.h library with the pow() function the memory code or ROM memory it's used untill 89\%. How can I do the same but useless too memory.
:=
:=Greating
:=CPB.

What types of numbers are you using? Could b be an integer? If so just use a loop. If b is not an integer could it be one of several fixed values? Maybe a switch case structure to solve for each of those values?

___________________________
This message was ported from CCS's old forum
Original Post ID: 10025
goyoko
Guest







Re: Calculus
PostPosted: Fri Dec 13, 2002 7:49 am     Reply with quote

:=:=Hello...
:=:=
:=:=I have a question about calc.
:=:=I wish put in the main program a potencial function y=a*x^b but when I use math.h library with the pow() function the memory code or ROM memory it's used untill 89\%. How can I do the same but useless too memory.
:=:=
:=:=Greating
:=:=CPB.
:=
:=What types of numbers are you using? Could b be an integer? If so just use a loop. If b is not an integer could it be one of several fixed values? Maybe a switch case structure to solve for each of those values?
:=

Hi.. Values are float. I'm covert a int16 variable to float variable to display in LCD.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10026
R.J.Hamlett
Guest







Re: Calculus
PostPosted: Fri Dec 13, 2002 9:02 am     Reply with quote

:=Hello...
:=
:=I have a question about calc.
:=I wish put in the main program a potencial function y=a*x^b but when I use math.h library with the pow() function the memory code or ROM memory it's used untill 89\%. How can I do the same but useless too memory.
:=
:=Greating
:=CPB.
Seriously, float arithmetic, is a very heavy user of ROM space. This effect is less of a problem with larger chips (for instance on the 18F252, I solve a fairly complex set of arithmetic, involving power, log, sin etc., and still have a reasonable amount of space. The space used also declines on these chips, where the more efficient memory access code, and the presence of the hardware multiplier help a lot.
One solution that works well if you have a limited input range, is to use scaled integers, instead of float values. With a bit of care, this can help a lot. I notice you mention (in your other post), using float with a printf. This can really cost in terms of RPM useage. Dealing with a similar problem, I converted the result of my arithmetic to an integer by multiplying by 100, then printed this to a string in memory (using sprintf), and manually added the decimal point. This used less than 3/4 the space of simply printing the float value.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 10028
Sherpa Doug
Guest







Re: Calculus
PostPosted: Fri Dec 13, 2002 1:05 pm     Reply with quote

:=Hi.. Values are float. I'm covert a int16 variable to float variable to display in LCD.

I avoid floats at all costs. Scaled integers such as Mr Hamlett describes are the way to go with small chips. As others on this board have heard, I measure ships in integer millimeters and only convert to meters for output, which I do a string manipulation rather than numerical manipulation.
If your only reason for using a float is to print to a LCD, you can definately do better with ints.

___________________________
This message was ported from CCS's old forum
Original Post ID: 10039
Mircea



Joined: 12 Jan 2007
Posts: 7
Location: Europe

View user's profile Send private message

Re: Calculus
PostPosted: Fri Apr 03, 2009 6:46 am     Reply with quote

Recent versions of CCS compiler offer %w format specifier.

Code:
printf(LCD_putc, "%4.1w", myIntVal);

So we can use (in many situations) integer type instead of float.
Please find %w format specifier into the documentation.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Apr 03, 2009 8:07 am     Reply with quote

Thanks for making the effort to answer a question on this forum.
But do you really think the original poster is still waiting after 6,5 years ... ??? Confused
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Fri Apr 03, 2009 11:22 am     Reply with quote

If he's making a PIC do floating point math--he might be.
Mircea



Joined: 12 Jan 2007
Posts: 7
Location: Europe

View user's profile Send private message

PostPosted: Wed Apr 08, 2009 7:02 am     Reply with quote

ckielstra wrote:
Thanks for making the effort to answer a question on this forum.
But do you really think the original poster is still waiting after 6,5 years ... ??? Confused


Mieux plus tard que jamais. Very Happy

The %w format specifier is recent.
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