Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
Implicit conversion from 64-bit signed integer (long) to Decimal in C#
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 MoreWhat is the difference between new/delete and malloc/ free in C/ C++?
new/ deleteThe new operator requests for the memory allocation in heap. If the sufficient memory is available, it initializes the memory to the pointer variable and returns its address.The delete operator is used to deallocate the memory. User has the privilege to deallocate the created pointer variable by this delete operator.Here is an example of new/delete operator in C++ language,Example#include using namespace std; int main () { int *ptr1 = NULL; ptr1 = new int; float *ptr2 = new float(299.121); int *ptr3 = new int[28]; *ptr1 = 28; cout
Read MoreJava Program to get full day name
To display the full day name, use the SimpleDateFormat(“EEEE”) as shown below −// displaying full-day name f = new SimpleDateFormat("EEEE"); String str = f.format(new Date()); System.out.println("Full Day Name = "+str);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 ...
Read MoreC# Exponential (“E”) Format Specifier
The ("E") format specifier converts a number to a string of the following form −"-d.ddd…E+ddd"Or"-d.ddd…e+ddd"Above, "d" is a digit (0-9).Prefix the exponent with an "E" or an "e".Exampleusing System; using System.Globalization; class Demo { static void Main() { double d = 3452.7678; Console.WriteLine(d.ToString("E", CultureInfo.InvariantCulture)); Console.WriteLine(d.ToString("E10", CultureInfo.InvariantCulture)); Console.WriteLine(d.ToString("e", CultureInfo.InvariantCulture)); Console.WriteLine(d.ToString("e10", CultureInfo.InvariantCulture)); } }Output3.452768E+003 3.4527678000E+003 3.452768e+003 3.4527678000e+003
Read MoreCompute modulus division by a power-of-2-number in C#
We have taken the number as the following −uint a = 9; uint b = 8;Above, a is a divisor and b is dividend.To compute modulus division.Exampleusing System; class Demo { static uint display( uint a, uint b) { return ( a & (b-1) ); } static public void Main () { uint a = 9; uint b = 6; Console.WriteLine( a + " modulus " + b + " = " + display(a, b)); } }Output9 modulus 6 = 1
Read MoreJava Program to display date and time information in lowercase
Firstly, create a Formatter and a Calendar object.Formatter f = new Formatter(); Calendar c = Calendar.getInstance();To display complete date and time information use the ‘c’ conversion character. However, to display it in lowercase, use ‘tc’ −f = new Formatter(); System.out.println(f.format("Date and Time (lowercase): %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(); System.out.println("Current date and time: "+cal.getTime()); ...
Read MoreC# Fixed-Point (“F”) Format Specifier
The ("F") format specifier converts a number to a string of the following form −"-ddd.ddd…"Above, "d" indicates a digit (0-9).Let us see an example.Here, if we will set (“F3”) format specifier to add three values after decimal places, for let’s say, 212.212.000The following is another example −Exampleusing System; using System.Globalization; class Demo { static void Main() { int val; val = 38788; Console.WriteLine(val.ToString("F",CultureInfo.InvariantCulture)); val = -344; Console.WriteLine(val.ToString("F3",CultureInfo.InvariantCulture)); val = 5656; Console.WriteLine(val.ToString("F5",CultureInfo.InvariantCulture)); } }Output38788.00 -344.000 5656.00000
Read Moresin() function in PHP
The sin() function Returns the sine of a number.Syntaxsin(num)Parametersnum − The number for which you want to Return the sine. A value in radians.ReturnThe sin() function Returns the arc sine of a number.ExampleOutput0.4794255386042-0.78332690962748ExampleLet us see another example −Output00.8414709848079-0.84147098480790.90929742682568
Read MoreParse Octal string to create BigInteger in Java
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 MoreC# Percent ("P") Format Specifier
The percent ("P") format specifier is used to multiply a number by 100.It converts the number into a string representing a % (percentage).We have the following double type −double val = .975746;If we will set (“P”) format specifier, then the above would result as −97.57 %In the same way, using (“P1”), would only include a single vale after decimal-point.97.6%Exampleusing System; using System.Globalization; class Demo { static void Main() { double val = .975746; Console.WriteLine(val.ToString("P", CultureInfo.InvariantCulture)); Console.WriteLine(val.ToString("P1", CultureInfo.InvariantCulture)); Console.WriteLine(val.ToString("P4", CultureInfo.InvariantCulture)); } }Output97.57 % 97.6 % 97.5746 %
Read More