Readymade with zero price tag and unlimited access, that is how I can describe a built-in-function. All programming languages having certain amount of built-in-function, which written as subroutine or function to solve a certain requirement, while writing a program you can, call these functions by sending arguments that required or with no arguments.
It is not that we cannot solve these, but when it is available, we just use it. Built-in-functions come in different types depending upon data types – Numeric, Date, String, Database etc. I will cover this topic in two weeks and with a few which we use frequently.
Numeric or math function to solve a mathematic routine like square root and other. Many math functions in Java return value is double type but you can take help of type casting to get it in integer. In java java.lang is default package so you do not need any extra package to be import but in C or C++, you have to include "math.h" but for min() and max() in C/C++ you require
"stdlib.h" or often "complex.h"
Note : Num - is the numeric argument you have to pass.It is not that we cannot solve these, but when it is available, we just use it. Built-in-functions come in different types depending upon data types – Numeric, Date, String, Database etc. I will cover this topic in two weeks and with a few which we use frequently.
Numeric or math function to solve a mathematic routine like square root and other. Many math functions in Java return value is double type but you can take help of type casting to get it in integer. In java java.lang is default package so you do not need any extra package to be import but in C or C++, you have to include "math.h" but for min() and max() in C/C++ you require
"stdlib.h" or often "complex.h"
Description | Basic | C & C++ | Java |
Returns the square root of a double value. | sqr(num) | sqrt(num) | Math.sqrt(num) |
Returns the absolute value of a double value. | abs(num) | abs(num) | Math.abs(num) |
Returns of value of the first argument raised to the power of the second argument. | pow(num,num) | Math.pow(num,num) | |
Returns the smaller of two Numeric values. | min(num,num) | Math.min(num,num) | |
Returns the larger of two Numeric values. | max(num,num) | Math.max(num,num) | |
Returns the trigonometric sine, cosine and tangent of an angle where argument should be in radian. | sin(num) cos(num) tan(num) | sin(num) cos(num) tan(num) | Math.sin(num) Math.cos(num) Math.tan(num) |
Returns the exponential number (i.e., 2.718...) raised to the power of a double value. | exp(num) | exp(num) | Math.exp(num) |
Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer. ceil(12.5) = 13, ceil(-12.5) = -12 | cint(num) | ceil(num) | Math.ceil(num) |
Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer. floor(12.5) = 12, floor(-12.5) = -13. | fix(num) | floor(num) | Math.floor(num) |
Returns a random number between 0.0 and 1.0 | rnd(num) | random() | Math.random() |
Return a double number that represents the closest integer to the double parameter. rint(2323.43) =23.0, rint(2323.83) =23.0 |
Conversion - while writing a program we often have to change a data type to another. In C/C++, you need to include "stdlib.h". Here some example
Description | Basic | C & C++ | Java |
Integer to String | str$(num) | itoa(num,string,10) * | Integer.toString(num) |
float to String | - do - | fcvt(num,ndigit,&dec,&sign) | Float.toString(num) |
double to String | - do - | Double.toString(num) | |
String to Integer | val(string) | Integer.parseInt(String) | |
String to Float | - do - | Float.parseInt(String) | |
String to Double | - do - | Double.parseInt(String) |
* 10 is the radix or base value, indicate that String value should be converted in Decimal. Binary (2), Octal (8) and in Hexadecimal (16).
Now these days Fortran and Pascal can be seen anywhere in the scenario, but some engineering Colleges having Fortran in their 3rd semester, so few Mathematical function for these programming languages are given below :
Now these days Fortran and Pascal can be seen anywhere in the scenario, but some engineering Colleges having Fortran in their 3rd semester, so few Mathematical function for these programming languages are given below :
Description | Fortran | Pascal |
Returns the square root of a double value. | sqrt(num) | sqrt(num) |
Returns the absolute value of a double value. | abs(num) | abs(num) |
Returns of value of the first argument raised to the power of the second argument. | sqr(num,num) | |
Returns the trigonometric sine, cosine and tangent of an angle where argument should be in radian. | sin(num) cos(num) tan(num) | sin(num) cos(num) tan(num) |
Returns the exponential number (i.e., 2.718...) raised to the power of a double value. | exp(num) | exp(num) |
This returns a real number whose value is the integer part of the real value x. For example, Int(8.3), give you 8 | int(num) | Int(num) |
Modulus eg. mod(8,5) will give you remainder 3. | mod(num,num) |
Next week coming with String functions. One thing I like to tell you, I often write my own packages for certain things and call my home made built-in functions, as I always like the challenge, but give you a tip too -
!!!Do not take too many challenges while appearing for exam, as exam itself is too challenging, happy finally time to say you Allez ciao!!!
No comments:
Post a Comment