Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Visitor
scc_tronix
Posts: 3
Registered: ‎01-27-2008
0

Need to calcultae nth power of a number (EDK).

Hi,
I am using EDK. For a microblaze, while doing program I need to take nth power of a number.
But when I do (n^m) then it gives me X-OR operation result.
How can I overcome this problem?
 
Please help me...!
 
~Sandeep
Expert Contributor
gszakacs
Posts: 5,253
Registered: ‎08-14-2007
0

Re: Need to calcultae nth power of a number (EDK).

In the C language, the caret (^) is the bitwise XOR operator and double-asterisk (**) is the power function.  So you need to write x**n to raise x to the nth power.
-- Gabor
Xilinx Employee
centaur19
Posts: 297
Registered: ‎08-01-2007
0

Re: Need to calcultae nth power of a number (EDK).

Hi Sandeep,

You could also use the pow(x, y) (double precision) or the powf(x, y) (single precision) functions.

Visitor
norton_allen
Posts: 16
Registered: ‎09-13-2007
0

Re: Need to calcultae nth power of a number (EDK).



gszakacs wrote:
In the C language,... double-asterisk (**) is the power function.

Uh, that would be Fortran. There is now power operator in C, only the floating point functions mentioned before.

Visitor
scc_tronix
Posts: 3
Registered: ‎01-27-2008
0

Re: Need to calcultae nth power of a number (EDK).

Hey thanks all.
I am able to solve the problem by using powf function and not (**).
As well increasing the onchip BRAM size from 16KB to 32KB.
Floating point powf function need some more memory space and hence was giving an error for Data2MEM execution.
 
Thanks to all ..!!
 
~Sandeep