Programming Articles

Page 9 of 2545

PHP round() Function

Malhar Lathkar
Malhar Lathkar
Updated on 11-Mar-2026 1K+ Views

Definition and UsageThe round() function proves useful in rounding any floating point number upto a desired precision level. Positive precision parameter causes the number to be rounded after decimal point, whereas with negative precision, rounding occurs before decimal point. Precision is 0 by default.For example, round(10.6) returns 11, round(10.2) returns 10. The function always returns a floating point number.This function also has another optional parameter called mode takes one of the redefined constants described later.Syntaxround ( float $value , int $precision , int $mode ) : floatParametersSr.NoParameter & Description1valueA float number to be rounded2precisionnumber of decimal digits to round to. ...

Read More

PHP sin() Function

Malhar Lathkar
Malhar Lathkar
Updated on 11-Mar-2026 298 Views

Definition and UsageThe sin() function returns the sine ratio of given angle in radians. In trigonometry, sine of an angle is defined as ratio of lengths of opposite side and hypotenuse.sin(x) = opposite/hypotenuseIf x=90 degree, sin(x) = 1 as opposite side of right angle is a hypotenuseThis function returns a float value.Syntaxsin ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP sin() function returns sine ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.ExampleOutputThis will produce following result −sin(3.1415926535898) = 1.2246467991474E-16

Read More

How to create a line chart for a subset of a data frame using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 680 Views

Subsetting is not a difficult thing in R but if we make our code short then it is a little tedious task because we will have to introduce code between codes and that creates confusion. Therefore, we must be very careful while writing a code inside another code. To create a line with subsetting the data frame using ggplot function of ggplot2 can be done by using subset function.Exampleggplot(subset(df,x1 %in% c("Sample1","Sample2","Sample3")))+ + geom_line(aes(x2,x3,group=x1,colour=x1))Output

Read More

How to add or multiply each element of a matrix to the corresponding element of another matrix in R, if these matrices are stored as a list?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 212 Views

Basic mathematical operations such as addition, subtraction, multiplication, and division are common for matrices and we often do that but if the matrices are stored as a list in R then these basic calculations are done differently as they are not direct objects. To add or multiply the matrices in a list, we can use Reduce function with the plus (+) or multiply (*) sign and the list name.ExampleMatrices_List

Read More

PHP sqrt() Function

Malhar Lathkar
Malhar Lathkar
Updated on 11-Mar-2026 2K+ Views

Definition and UsageThe sqrt() function returns square root of a positive float number. Since square root for negative number is not defined, it returns NAN. This is one of the most commonly used functions.This function always returns a floating point number.Syntaxsqrt ( float $arg ) : floatParametersSr.NoParameter & Description1arga number whose square root is to be obtainedReturn ValuesPHP sqrt() function returns square root of the given arg number. For negative number, the function returns NAN.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.ExampleOutputThis will produce following result −sqrt(-1) = NAN

Read More

How to create a new data frame for the mean of rows of some columns from an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 970 Views

Finding row means help us to identity the average performance of a case if all the variables are of same nature and it is also an easy job. But if some of the columns have different type of data then we have to extract columns for which we want to find the row means. Therefore, we can create a new data frame with row means of the required columns using rowMeans function.Examplerow_means_3.4_cols_df

Read More

PHP srand() Function

Malhar Lathkar
Malhar Lathkar
Updated on 11-Mar-2026 381 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.ExampleOutputThis may produce following result−rand()=548287992

Read More

PHP tan() Function

Malhar Lathkar
Malhar Lathkar
Updated on 11-Mar-2026 207 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

How to a split a continuous variable into multiple groups in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 882 Views

Splitting a continuous variable is required when we want to compare different levels of a categorical variable based on some characteristics of the continuous variable. For example, creating the salary groups from salary and then comparing those groups using analysis of variance or Kruskal-Wallis test. To split a continuous variable into multiple groups we can use cut2 function of Hmisc package −Exampledf$Salary_Group

Read More

Matching Nonprintable Characters using Java regex

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 1K+ Views

There are 7 common non printable characters used in general and each character has its own hexadecimal representation.NamecharactersHexa-decimal representationbell\a0x07Escape\e0x1BForm feed\f0x0CLine feed0x0ACarriage return\r0X0DHorizontal tab\t0X09Vertical tab\v0X0BExample 1import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample1 {    public static void main(String[] args) {       Scanner sc = new Scanner(System.in);       System.out.println("Enter input text: ");       String input = sc.nextLine();       String regex = "\x09";       //Creating a pattern object       Pattern pattern = Pattern.compile(regex);       //Matching the compiled pattern in the String       Matcher matcher = ...

Read More
Showing 81–90 of 25,445 articles
« Prev 1 7 8 9 10 11 2545 Next »
Advertisements