Samual Sam

Samual Sam

1,507 Articles Published

Articles by Samual Sam

Page 15 of 151

pi() function in PHP

Samual Sam
Samual Sam
Updated on 11-Mar-2026 176 Views

The pi() function Returns the value of Pi (π).Syntaxpi()ParametersNAReturnThe pi() function Returns the approximate value of PI. This value is a floating point value.3.1415926535898ExampleOutput3.1415926535898ExampleLet us see another example to get the value of PIOutput3.1415926535898

Read More

Display complete date and time information using Formatter in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 171 Views

Firstly, create a Formatter and Calendar object.Formatter f = new Formatter(); Calendar cal = Calendar.getInstance();Now display the current date and time. We have shown the date here in both lowercase and uppercase −f = new Formatter(); System.out.println(f.format("Date and Time (lowercase): %tc", cal)); f = new Formatter(); System.out.println(f.format("Date and Time (uppercase): %Tc", cal));The following is an example −Exampleimport java.util.Calendar; import java.util.Formatter; public class Demo { public static void main(String args[]) { Formatter f = new Formatter(); Calendar cal = Calendar.getInstance(); ...

Read More

rad2deg() function in PHP

Samual Sam
Samual Sam
Updated on 11-Mar-2026 103 Views

The rad2deg() function converts radian value to degree value. It Returns the equivalent of radia value val in degrees.Syntaxrad2deg(val)Parametersval − The radian value to be converted into degree.ReturnThe rad2deg() function Returns the equivalent of val in degrees.ExampleOutput180ExampleLet us see another example −Output90ExampleLet us see another example −Output22.5

Read More

Display the day in week using SimpleDateFormat('E') in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 725 Views

To display the day in week, use the SimpleDateFormat(“E”) as shown below −Format f = new SimpleDateFormat("E"); String strDayinWeek = f.format(new Date()); System.out.println("Day in week = "+strDayinWeek);Since, we have used the Format and SimpleDateFormat class above, therefore import the following packages. With that, we have also used the Date.import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date;Exampleimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo {    public static void main(String[] args) throws Exception {       // displaying current date and time       Calendar cal = Calendar.getInstance();       SimpleDateFormat simpleformat = new SimpleDateFormat("dd/MMMM/yyyy hh:mm:s");   ...

Read More

Implicit conversion from 64-bit signed integer (long) to Decimal in C#

Samual Sam
Samual Sam
Updated on 11-Mar-2026 335 Views

The long type represents a 64-bit signed integer.To implicitly convert a 64-bit signed integer to a Decimal, firstly set a long value.long val = 989678876876876;To convert long to decimal, assign the value.dec = val;Let us see another example −Exampleusing System; public class Demo {    public static void Main() {       long val = 76755565656565;       decimal dec;       Console.WriteLine("Implicit conversion from 64-bit signed integer (long) to Decimal");       dec = val;       Console.WriteLine("Decimal : "+dec);    } }OutputImplicit conversion from 64-bit signed integer (long) to Decimal Decimal : 76755565656565

Read More

Parse Octal string to create BigInteger in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 217 Views

To parse the octal string to create BigInteger, use the following BigInteger constructor and set the radix as 8 for Octal −BigInteger(String val, int radix)This constructor is used to translate the String representation of a BigInteger in the specified radix into a BigInteger.In the below example, we have set the BigInteger and radix is set as 8.BigInteger one, two; one = new BigInteger("12"); two = new BigInteger("4373427", 8);The following is the complete example −Exampleimport java.math.*; public class Demo {    public static void main(String[] args) {       BigInteger one, two;       one = new BigInteger("12");   ...

Read More

C# Program to determine the difference in hours between two dates

Samual Sam
Samual Sam
Updated on 11-Mar-2026 11K+ Views

Set two dates.DateTime date1 = new DateTime(2018, 7, 15, 08, 15, 20); DateTime date2 = new DateTime(2018, 8, 17, 11, 14, 25);Now, get the difference between two dates.TimeSpan ts = date2 - date1;Get the result i.e. the difference in hours.ts.TotalHoursLet us see the complete code.Exampleusing System; using System.Linq; public class Demo {    public static void Main() {       DateTime date1 = new DateTime(2018, 7, 15, 08, 15, 20);       DateTime date2 = new DateTime(2018, 8, 17, 11, 14, 25);       TimeSpan ts = date2 - date1;       Console.WriteLine("No. of Hours (Difference) = {0}", ts.TotalHours);    } }OutputNo. of Hours (Difference) = 794.984722222222

Read More

Right pad a string in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 1K+ Views

To right pad a string, use the String.format and set the spaces.String.format("%1$-" + 20 + "s", "demotext"));If you add 30 above, it will display the next string after 30 spaces from the beginning.String.format("%1$-" + 30 + "s", "demotext")The following is an example.Examplepublic class Demo {    public static void main(String []args){       System.out.print(String.format("%1$-" + 20 + "s", "demotext"));       System.out.println("Right padded!");    } }Outputdemotext Right padded!

Read More

Parse hexadecimal string to create BigInteger in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 2K+ Views

To parse the hexadecimal string to create BigInteger, use the following BigInteger constructor and set the radix as 16 for Hexadecimal.BigInteger(String val, int radix)This constructor is used to translate the String representation of a BigInteger in the specified radix into a BigInteger.In the below example, we have set the BigInteger and radix is set as 16 −Exampleimport java.math.*; public class Demo {    public static void main(String[] args) {       BigInteger one, two;       String hexStr = "290f98";       one = new BigInteger("250");       // parsing       two = new ...

Read More

Parsing and Formatting a Big Integer into Binary in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 2K+ Views

Firstly, take two BigInteger objects and set values.BigInteger one, two; one = new BigInteger("99"); two = new BigInteger("978");Now, parse BigInteger object “two” into Binary.two = new BigInteger("1111010010", 2); String str = two.toString(2);Above, we have used the following constructor. Here, radix is set as 2 for Binary for both BigInteger constructor and toString() method.BigInteger(String val, int radix)This constructor is used to translate the String representation of a BigInteger in the specified radix into a BigInteger.The following is an example −Exampleimport java.math.*; public class Demo {    public static void main(String[] args) {       BigInteger one, two;       ...

Read More
Showing 141–150 of 1,507 articles
« Prev 1 13 14 15 16 17 151 Next »
Advertisements