Fletcher's Checksum

Chandu yadav
Updated on 30-Jun-2020 07:38:08

5K+ Views

Fletcher checksum is an error – detection technique that uses two checksums to determine single-bit errors in a message transmitted over network channels. It is a block code technique that was devised by John G. Fletcher in 1970s at Lawrence Livermore Labs, USA.The checksums are created based on the data values in the data blocks to be transmitted and appended to the data. When the receiver gets this data, the checksums are re-calculated and compared with the existing checksums. A non-match indicates an error.The error-detection capabilities of this method is nearly same as that of Cyclic Redundancy Check (CRC) but ... Read More

PHP Predefined Mathematical Constants

Malhar Lathkar
Updated on 30-Jun-2020 07:36:18

194 Views

Definition and UsageConstantValueDescriptionM_PI3.14159265358979323846PiM_E2.7182818284590452354Euler Number eM_LOG2E1.4426950408889634074log2 eM_LOG10E0.43429448190325182765log10 eM_LN20.69314718055994530942loge 2M_LN102.30258509299404568402loge10M_PI_21.57079632679489661923pi/2M_PI_40.78539816339744830962pi/4M_1_PI0.318309886183790671541/piM_2_PI0.636619772367581343082/piM_SQRTPI1.77245385090551602729sqrt(pi)M_2_SQRTPI1.128379167095512573902/sqrt(pi)M_SQRT21.41421356237309504880sqrt(2)M_SQRT31.73205080756887729352sqrt(3)M_SQRT1_20.707106781186547524401/sqrt(2)M_LNPI1.14472988584940017414loge(pi)M_EULER0.57721566490153286061Euler constantPHP_ROUND_HALF_UP1Round halves upPHP_ROUND_HALF_DOWN2Round halves downPHP_ROUND_HALF_EVEN3Round halves to even numbersPHP_ROUND_HALF_ODD4Round halves to odd numbersNANNANNot A NumberINFINFInfinity

Replace 0 with NULL in MySQL

George John
Updated on 30-Jun-2020 07:36:05

2K+ Views

You can use NULLIF() from MySQL to replace 0 with NULL. The syntax is as follows −SELECT *, NULLIF(yourColumnName, 0) as anyVariableName from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table Replace0WithNULLDemo    -> (    -> Id int NOT NULL auto_increment,    -> Name varchar(20),    -> Marks int,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.53 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into Replace0WithNULLDemo(Name, Marks) values('John', ... Read More

PHP tanh Function

Malhar Lathkar
Updated on 30-Jun-2020 07:34:05

150 Views

Definition and UsageThe tanh() function returns the hyperbolic tangent ratio of given angle in radians. In trigonometry, hyperbolic tangent ratio is defined as.tanh(x) = sinh()/tanh()This function returns a float value .Syntaxtanh ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP tanh() function returns 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 tanh(pi/2) and returns 2.5091784786581 which is also the result of formula (ex + e-x))/2 −OutputThis will produce following result −tanh(pi) = 0.91715233566727 using formula = 0.91715233566727Example Live DemoFollowing example uses deg2rad() ... Read More

Convert Datetime to a Number in MySQL

Arjun Thakur
Updated on 30-Jun-2020 07:33:30

2K+ Views

To convert the date time to a number in MySQL, the syntax is as follows −SELECT UNIX_TIMESTAMP(yourColumnName) as anyVariableName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table DateTimeToNumberDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> releasedDate datetime,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into DateTimeToNumberDemo(releasedDate) values(now()); Query OK, 1 row affected (0.19 sec) mysql> insert into ... Read More

Check if Varchar Contains Percent Sign in MySQL

Ankith Reddy
Updated on 30-Jun-2020 07:31:59

447 Views

To find out a varchar contains a percent sign in MySQL, you can use LIKE operator. The syntax is as follows −SELECT * FROM yourTableName WHERE yourColumnName like '%|%%' escape '|';To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table FindPercentInVarcharDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Words varchar(30),    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.51 sec)Insert some records with % sign using insert command. The query is as follows −mysql> insert into FindPercentInVarcharDemo(Words) values('This is ... Read More

PHP tan() Function

Malhar Lathkar
Updated on 30-Jun-2020 07:31:07

164 Views

Definition and UsageThe tan() function returns the tangent ratio of given angle in radians. In trigonometry, tangent of an angle is defined as ratio of lengths of opposite side and adjacent side.tan(x) = opposite/adjacenttangent of an angle is also defined as ratio of its sine and cosinetan(x) = sin(x)/cos(x)If x=45 degree, tan(x) = 1 as in a right angled traingle, opposite and adjacent sides are qual.This function returns a float value.Syntaxtan ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP tan() function returns tangent ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP ... Read More

Change Date Format to DD-MM-YYYY in PHP MySQL

Chandu yadav
Updated on 30-Jun-2020 07:30:05

3K+ Views

You can change the date format in PHP using date() fucntion. The syntax is as follows −date(d/m/Y, yourDateTimeVariable);In PHP, convert string to date using strtodate(). Here is the PHP code used to format the datetime −$LogintDate = strtotime('2019-01-12'); echo date('d/m/Y', $LogintDate);The snapshot of code is as follows −The following is the output −12/01/2019You can achieve in MySQL with the help of date_format() function. The syntax is as follows −SELECT DATE_FORMAT(yourColumnName, ’%d/%m/%Y’) as anyVariableName FROM yourTableName;To understand the above syntax, let us create a table −mysql> create table Date_FormatDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> ... Read More

PHP srand Function

Malhar Lathkar
Updated on 30-Jun-2020 07:29:27

339 Views

Definition and UsageThe srand() function is used to seed the random number generaror. Seeding initializes the random number generator. Most random number generators need initial seeding. In PHP, use of srand() function is optional as it is done automatically.This function doen't have any return value.Syntaxsrand ([ int $seed ] ) : voidParametersSr.NoParameter & Description1seedan integer to be used as seed. If not given, a random number is givenReturn ValuesThis function doesn't return any value.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoThis example the random number generator is first initialized before employing ... Read More

MySQL Limit to Select a Single Row

George John
Updated on 30-Jun-2020 07:28:32

488 Views

To select a single row in MySQL, you can use LIMIT. At first, let us create a table. The query to create a table is as follows −mysql> create table selectWithPrimaryKey    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(20),    -> Age int,    -> Marks int,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into selectWithPrimaryKey(Name, Age, Marks) values('Larry', 24, 98); Query OK, 1 row affected (0.15 sec) mysql> insert into ... Read More

Advertisements