Math & Conversion Functions

These functions are used for various algebric and trignometric operations:

1. abs()

The function abc() calculates the absolute vlaue of an integer. The argument to this function is an integer. It has a prototype in the header file math.h

2. fabs()

The function fabs() returns the absolute value of an argument. The argument to this function is a number of type float or double. It has a prototype in the header file math.h

3. exp()

The function exp() returns the exponential of its argument. The argument to the function is a float or a double. It has a prototype in the header file math.h.

4. frexp()

The function frexp() splits a real number into mantissa and exponent. this argument to this function is a double. It has a prototype in the header file math.h.

5. fmod()

The function fmod() returns the floating point remainder of a division operation, such as a/b. the remainder is the portion to the right of the decimal part of the result of the division operation. Variables a and b are of type double and the value returned is also of type double. However the sign of the returned value is same as that of a. It has a prototype in the header file math.h.

6. log()

The function log() takes an argument of type double and returns the natural logarithm of the argument. It has a prototype in the header file math.h

7. log10()

the function log10() takes an argument of type double and returns the logarithm to the base 10 of the argument. It has a prototype in the header file math.h.

8. modf()

The function modf() takes arguments n and m of type double and splits n into an integer part and a fraction part. The integer part is assigned to m and the fractional part is returned to n. It has a prototype in the header file math.h.

9. pow()

The function pow() takes two artuments a and y of type double and returns xy . It has a prototype in the header file math.h.

10. sqrt()

The function sqrt() takes one argument of type double and returns a non-negative square root of the argument. It has a prototype in the header file math.h.

11. sin()

the function sin() takes an angle as argument of type double and returns the sine of the angle. It has a prototype in the header file math.h.

12. cos()

The function cos() takes an angle as an argument of type double and returns the cosine of the angle. It has a prototype in the header file math.h

Conversion Functions

1. itoa()

The function itoa() converts an integer to a string. It converts a value to a null terminated string and stores the result in the string. The argument of itoa() function is an integer. It has a prototype in the head file stdlib.h

If the value is negative and radix is 10, itoa() sets the first character of the string to minus. The space allocated for the string must be large enough to hold the returned string, including the terminating null character. The function itoa() can return up to 17 bytes.

2. ltoa()

The function ltoa() converts a long to a string. It converts a value to a null terminated string and stores the result in the string. The argument of ltoa() function is a long integer. It has a prototype in the header file stdlib.h

If the value is negative and radix is 10, ltoa() sets the first character of the string to minus sign. The space allocated for the string must be large enough to hold the returned string, including the terminating null character. The function ltoa() can return up to 33 bytes.

3. atoi()

The function atoi() converts a string to an integer. It returns the converted value of the input string. If the string can not be converted, it returns zero. The function atoi() recognizes:

An optional string of tabs and spaces[ws]

An optional sign[sn]

A string of digits[ddd]

The characters in a string must match the following format:

[ws] [sn] [ddd]

In atoi(), the first unrecognised character ends the conversion. There are no provisions for overflow (results are undefiend).

4. atol()

The function atol() converts a string to a long integer. It returns the converted value of the input string. If the string can not be converted, it returns zero. The function atol() recognizes:

An optional string of tabs and spaces[ws]

An optional sign[sn]

A string of digits[ddd]

The characters in a string must match the following format:

[ws] [sn] [ddd]

In atol(), the first unrecognised character ends the conversion. There are no provisions for overflow (results are undefiend).

HOME LEARN C++ PREVIOUS NEXT