Found 26504 Articles for Server Side Programming

PHP ceil() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:35:17

347 Views

Definition and UsageThe ceil() function is an in-built function in PHP iterpreter. This function accepts any float number as argument and rounds it up to the next highest integer.This function always returns a float number as range of float is bigger than that of integer.Syntaxceil ( float $num ) : floatParametersSr.NoParameter & Description1numThe number to be rounded up.Return ValuesPHP ceil() function returns the smallest integer value that is bigger than or equal to given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example rounds 5.78 to its next highest integer which ... Read More

PHP bindec() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:34:02

232 Views

Definition and UsageThe bindec() function returns decinmal equivalent of a binary number represented as a string argument. Binary number inside string is interpreted as unigned integer.This function returns a decimal integer. However, it may return float for size reasons.Syntaxbindec ( string $binary_string ) : numberParametersSr.NoParameter & Description1binary_stringA string containing binary number representation. Invalid characters (other than 1 and 0) are ignored.Return ValuesPHP bindec() function returns decimal equivalent of given binary number inside string.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates decimal equivalent of '1101' and returns 13 −Read More

PHP base_convert() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:31:54

503 Views

Definition and UsageThe base_convert() function is versatile utility to convert a number with one base to another. The base is not restricted to binary, octal, hexadecimal or decimal. It can be any number between 2 and 36.First argument to this function is a string that can contain alpha-numeric characters. Digits in a number with base>9 will be represented by alphabets a - z such that 10 is represented by 'a', 11 by 'b' upto 35 by 'z'For example base_convert('1001', 2, 10) converts '1001' from binary to decimal number which is 9Syntaxbase_convert ( string $number , int $frombase , int $tobase ... Read More

PHP atanh() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:29:17

217 Views

Definition and UsageThe atanh() function returns the inverse hyperbolic tangent ratio of given given parameter. In other words, the return value of atanh() is hyperbolic tangent of given parameter. A inverse hyperbolic tangent function is defined as .atanh(x) = 0.5Xlog((1+x)/(1-x))This function returns a float value .Syntaxatanh ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value whose inverse hyperbolic tangent is to be calculatedReturn ValuesPHP atanh() function returns inverse hyperbolic tangent ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates atanh(pi/4) and returns which is also ... Read More

PHP atan2() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:29:52

241 Views

Definition and UsageThe atan2() function calculates arc tan of two variablesatan2(y, x) returns the arc tangent of the two numbers x and y. although it is similar to atan(y)/atan(x), the signs of both x and y are used to determine the quadrant of the result. Accordingly for values of x and y atan2() isatan(y/x) if x>0atan(y/x)+pi if x>0atan(y/x)-pi if xOutputThis will produce following result −atan2(5, -5) = 2.3561944901923Example Live DemoFollowing program computes atan2(5, 0) and returns 1.570796326795 (M_PI_2) −OutputThis will produce following result −atan2(5, 0) = 1.5707963267949Example Live DemoFollowing example computes atan2(0, 0) and returns 0OutputThis will produce following result −atan2(0, 0) ... Read More

PHP atan() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:24:18

273 Views

Definition and UsageThe atan() function returns the arc tan or tan inverse of arg in radians. atan() is the inverse function of tan(). Therefore if tan(x)=y, atan(y)=x.For example, tan(pi/3)= 1.73205080757 (Squre Root of 3) and atan(1.73205080757)=1.04719755 rad which is equal to pi/3.This function returns a float value .Syntaxatan ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point number whose arc tan is to be calculated.Return ValuesPHP atan() function returns arc tan of given number. It is angle represented in radians. Returned value is between -pi/2 and pi/2PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well ... Read More

PHP asinh() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:22:30

236 Views

Definition and UsageThe asinh() function calculates inverse of hyperbolic sine of given parameter. In other words, the return value of asinh() is hyperbolic sine of given parameter. A inverse hyperbolic sine function is defined asasinh(x) = log(x+sqrt(pow(x, 2)+1))This function returns a float value.Syntaxasinh( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value whose inverse hyperbolic sine is to be calculatedReturn ValuesPHP asinh() function returns inverse hyperbolic sine ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates asinh(pi/2) which we can verify using the definition −OutputThis will ... Read More

Image Smoother in C++

Arnab Chakraborty
Updated on 11-Jun-2020 12:21:54

408 Views

Suppose we have a 2D matrix M representing the gray scale of an image, we have to design a smoother to make the gray scale of each pixel becomes the average gray scale (rounding down) of all the 8 surrounding pixels and itself. If a cell has less than 8 surrounding cells, convert all possible pixels.So, if the input is like111101111then the output will be000000000To solve this, we will follow these steps −R := row count of MC := column count ofDefine an array d = { -1, 0, 1 }Define one 2D array res of size (R x C)for ... Read More

Robot Return to Origin in C++

Arnab Chakraborty
Updated on 11-Jun-2020 12:18:04

342 Views

Suppose there is a robot and its starting position is (0, 0). If we have a sequence of its movements, we have to check whether this robot ends up at (0, 0) after it completes its moves.The move sequence is given as a string, and the character moves[i] represents its ith move. Symbols are R for right, L for left, U for up, and D for down. If the robot returns to the origin after it finishes all of its moves, return true. Otherwise, return false.So, if the input is like "RRULLD", then the output will be true, Right two-unit, ... Read More

Two Sum IV - Input is a BST in C++

Arnab Chakraborty
Updated on 11-Jun-2020 12:16:29

201 Views

Suppose we have a Binary Search Tree and one target value; we have to check whether there exist two elements in the BST such that their sum is equal to the given target or not.So, if the input is likethen the output will be True.To solve this, we will follow these steps −Define an array vDefine a function inorder(), this will take root, if root is null, then −returninorder(left of root)insert value of root into vinorder(left of root)Define a function findnode(), this will take k, n := size of vwhile i < j, do −t := v[i] + v[j]if t ... Read More

Advertisements