Absolute value of a floating-point (double). This function is implemented in internal.c as a compatibility function for the labtalk version of abs(x) function. Please note that this function will simply call the fabs(x) function.
double abs( double x )
int abs( int n )
Return the absolute value of a double.
Returns the absolute value of an integer.
EX1
void abs_ex1() { double x = -5.9; double val = abs(x); printf("abs(%f) = %f\n", x, val); }
EX2
// This program computes and displays the absolute values of several numbers. #include <origin.h> int test_abs() { int nn; nn = abs( 0 ); out_int("abs(0)=", nn); //output should be abs(0)=0 ASSERT( nn == 0 ); nn = abs( -9 ); out_int("abs(-9)=", nn); //output should be abs(-9)=9 ASSERT( nn == 9 ); nn = abs( 200 ); out_int("abs(200)=", nn); //output should be abs(200)=200 ASSERT( nn == 200 ); nn = abs( -3.5 ); out_int("abs(-3.5)=", nn); //output should be abs(-3.5)=3 ASSERT( nn == 3 ); return 1; }
Absolute value (for integers). Note that this built-in C library abs function returns an int while the LabTalk abs function returns a double. The standard C library function fabs should typically used for doubles. To making it easier for Origin users, especially in defining fitting functions, an Origin C version of abs(double) has been added into internal.c, which is compiled automatically on Origin startup.
fabs
origin.h