Pow pIC

Status
Not open for further replies.

0mega

New Member
Hi guyz

How can i do a floating point pow operation on a pic (18F452) ?

ie. pow (2.1, 3.4)


I am using microchip C-18 suite

CHeerz, JB
 
:x
Floating point operations without FPU is time consuming task in CPUs and FPU presence in this case is recommended.
In case of a uC this is a unusual request but can be done with a lot of processing on 8 bits I guess.
Do a simple search on google with "floating point" and will found some articles about floating point representation and working.
 
Microchip have floating point application notes, and there is code on the PICList - but generally it's best not to use floating point, it's very slow and inaccurate. By careful scaling of the numbers you can usually use integer maths instead, far faster and giving perfect accuracy.

If you are using a C compiler, doesn't it already provide floating point routines anyway?.

Also, what is 'pow'?.
 
"pow" raises one number to another and returns the result. You're probably right, it might be better to use integers, but the nature of this unfortunately limits me to using floats .

Speed is not TOO Much of a concern, as long as my routine can do two samples a second that's fine

Anyway, accuracy is not a HUGE concern (ie. 1 decimal place is FINE)....

CYa
JB
 

Right, raising one number to the power of another, I've never heard it called 'pow' before.

Here's some assembler code for doing it
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…