UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer ubertekgfx
Observer
7,095 Views
Registered: ‎02-05-2008

Absolute value of an int

I know of fabs for doubles, but I am looking to get the absolute value of an int. Unlike in C++ or C, abs doesn't exist in the Xilinx world. I do not wish to do something like (int)fabs((double)iValue). Any suggestions?
0 Kudos
3 Replies
Observer ubertekgfx
Observer
7,092 Views
Registered: ‎02-05-2008

Re: Absolute value of an int

I could of course perform: iValue *= -1 but I would expect Xilinx would have a compiler function equivilant to C's abs.
0 Kudos
Xilinx Employee
Xilinx Employee
7,088 Views
Registered: ‎01-18-2008

Re: Absolute value of an int

Why would you think abs() is not available? Did you include <stdlib.h>?
0 Kudos
Observer ubertekgfx
Observer
7,058 Views
Registered: ‎02-05-2008

Re: Absolute value of an int

omg.
 
No I didn't have it included. :O I thought it had been since I am already using fabs() and it didn't complain. I guess fabs and abs are not contained within the same header file.
 
Thanks!
0 Kudos