Main Site Documentation

How to convert arduino's (C) labs() function to C#?


#1

Hello
i’m trying to implement the arc function into my CNC controller program. which is based on the code from gbrl.
Now i have the following code:

double millimeters_of_travel = hypot(angular_travel*radius, labs(linear_travel));

I have found already a replacement for the hypot(); function but i have no idea what labs(); should do. I have already tried to google it but i did not found anything useful.

Can someone help?
Thanks


#2

I think it just returns an absolute value.

Edit. just checked. Yes, labs is the long version of the abs.

From stdlib.h:


/** The labs() function computes the absolute value of the long integer
    \c i.
   \note The abs() and labs() functions are builtins of gcc.
*/
extern long labs(long __i) __ATTR_CONST__;