Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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 :D

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

CYa
JB
 
0mega said:
"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 :D

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

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.

Latest threads

New Articles From Microcontroller Tips

Back
Top