Sunday 3 March 2013

Behaviour of some Math.h functions

Today,I use some basic type of math.h functions and try to understand their behaviour.Here are some math.h functions which we use for study:-
1)abs
2)fabs
3)ceil
4)floor

1) abs :-This function returns absolute value of parameter.If a parameter having a value of -4 then it returns its value 4.It always takes and return int value.
2)fabs:-This is also having behaviour like abs But It always takes a double & returns double.F stands here
for floating-point argument.
3)ceil:-It calculates the ceiling value of parameter.It mean if a parameter having a value 4.1 then it returns 5 and value of a parameter is -4.1 then it returns 4.
4)floor:-It calculates the floor value of parameter .It mean if a parameter having a value 4.1 then it returns 4 and value of a parameter is -4.1 then it returns 5.

here is the snapshot of this program:-





Rounding a deimal number in C:-We can round the decimal number in C with following two methods:-

1)   FLOATVALUE = FLOOR(FLOATVALUE+0.5);
2)  FLOATVALUE = INT (FLOATVALUE+ 0.5);

No comments:

Post a Comment