Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - The difference between abs and fbs in C language
The difference between abs and fbs in C language
1, input parameter types are different:

ABS is an absolute value function, the input parameter type of fabs function is integer, and the input parameter type of FABS function is floating point.

2. The output parameter types are different:

The output parameter type of ABS function is integer, and the output parameter type of f ABS function is floating point.

3. Different functions:

Fabs function is to find the absolute value of floating-point number X, and abs function is to find the absolute value of integer.

4. The referenced header files are different:

The header file referenced by abs function is stdlib.h, and the header file referenced by fabs function is math.h

Extended data:

Application of fbs function;

This method can filter the sampled signal through program judgment. If the sensor is unstable due to frequent random interference, it will cause serious distortion.

The method is as follows: According to the production experience, determine the maximum allowable deviation △× value of two cross-sampling. If the signal phase difference of two consecutive samples is greater than △×, it indicates that the input is an interference signal and should be removed; Take the last sampling value as the current sampling value. If it is less than or equal to △×, it means that it is unaffected and the current sampling value is valid. This method is suitable for measuring systems that sample slowly changing physical parameters, such as temperature and physical location.

The function of C program for program judgment filtering is as follows:

Floating-point program detection filter (floating-point old value new value [], floating-point x) (

Floating point sample _ value

if(fabs(old _ new _ value[ 1]_ old _ new _ value[0])gt; X) sample value = old value new value [0];

Otherwise sample _ value = old _ new _ value [1];

Retrun (sample value);

}

The function call needs a one-dimensional binary array (old_new_value[2]) to store the last sampling value (old_new_value[0],) and the current sampling value (old_new_value[ 1]), where sample_value in the function represents the valid sampling value and x represents the maximum allowable value of two samples determined by experience.

Baidu encyclopedia -ABS

Baidu Encyclopedia-Wafer Factory Function