+ 1
What is this abs function of math.h
4 Réponses
+ 13
y-x is -1,
so abs(y-x) = abs(-1) = 1
+ 10
abs gives you the distance from your number to 0;
e.g
abs from -5 would be 5
abs from 5 would be also 5
+ 5
It represents the modulus function of mathematics, which is defined as:
{ x, if x>0
f(x) = { 0, if x=0
{ -x, if x<0
y-x is <0, so it will be negative of y-x, which results in 1...
Also note that abs is in stdlib.h, math.h has fabs which satisfies same purpose...
+ 1
If x=5 and y=4 then z= abs(y-x) means.?