- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The JavaScript Bitwise operators consider the operands as a sequence of 32 bits. The following bitwise operators are available in JavaScript −Sr.No.Operator & Operator Name1&Bitwise AND2|Bitwise OR3^Bitwise XOR4~Bitwise NOT5Bitwise Signed right shift7>>>Bitwise Zero-fill right shiftLet’s see an example of JavaScript Bitwise OR(|) operator.ExampleIf one of the bits are 1, then 1 is returned when Bitwise OR (|) operator is used. You can try to run the following code to learn how to work with JavaScript Bitwise OR Operator − document.write("Bitwise OR Operator"); // 7 = 00000000000000000000000000000111 // 1 = 00000000000000000000000000000001 document.write(7 | 1);
The "D" (or decimal) format specifier works for integer type. It converts a number to a string of decimal digits (0-9).Let’say the following is our number.int val = 467;Now to return the result as 0467, use the following decimal format specifier.val.ToString("D4")Let us see another example.Example Live Demousing System; using System.Globalization; class Demo { static void Main() { int val; val = 877; Console.WriteLine(val.ToString("D")); Console.WriteLine(val.ToString("D4")); Console.WriteLine(val.ToString("D8")); } }Output877 0877 00000877
If both the bits are 1, then 1 is returned when Bitwise AND (&) operator is used.ExampleYou can try to run the following code to learn how to work with JavaScript Bitwise AND Operator − document.write("Bitwise AND Operator"); // 7 = 00000000000000000000000000000111 // 1 = 00000000000000000000000000000001 document.write(7 & 1);
To get the value of the usemap attribute of a link in JavaScript, use the useMap property. The usemap attribute is used to tell that the document is html (text/html) or css (text/css), etc.Client-side image maps are enabled by the usemap attribute for the tag and defined by special and extension tags. The image that is going to form the map is inserted into the page using the element as normal, except that it carries an extra attribute called usemap.ExampleYou can try to run the following code to get the value of the usemap attribute of a link ... Read More
Use the match() method to match a regular expression against a string in JavaScript. You can try to run the following code to match a regular expression −The following is the parameter −match( param ) − A regular expression object.ExampleYou can try to run the following code to match a regular expression against a string − JavaScript String match() Method var str = "For more information, see Chapter 3.4.5.1"; var re = /(chapter \d+(\.\d)*)/i; var found = str.match( re ); document.write(found );
Int64 represents a 64-bit signed integer. To represent it as a string, use the ToString() method.Firstly, declare and initialize an Int64 variable.long val = 8766776;Now, represent it as a string.val.ToString()Let us see the complete example.Example Live Demousing System; class Demo { static void Main() { long val = 8766776; Console.Write("Long converted to string = "+val.ToString()); } }OutputLong converted to string = 8766776
To represent Int64 as a Binary string in C#, use the ToString() method and set the base as the ToString() method’s second parameter i.e.16 for Hexadecimal.Int64 represents a 64-bit signed integer.Firstly, set an Int64 variable.long val = 947645;Now, convert it to a hex string by including 16 as the second parameter.Convert.ToString(val, 16)ExampleLive Demousing System; class Demo { static void Main() { long val = 947645; Console.WriteLine("Long: "+val); Console.Write("Hex String: "+Convert.ToString(val, 16)); } }OutputLong: 947645 Hex String: e75bd
The "#" custom format specifier works as a digit-placeholder symbol.If the value to be formatted has a digit in the position where the "#" symbol appears in the format string, then that digit is copied to the resultant string.We have set a double type here.double d; d = 4.2;Now, let us use the “#” custom specifier.d.ToString("#.##", CultureInfo.InvariantCulture)Here are other examples.Example Live Demousing System; using System.Globalization; class Demo { static void Main() { double d; d = 4.2; Console.WriteLine(d.ToString("#.##", CultureInfo.InvariantCulture)); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0:#.##}", d)); d = 345; ... Read More
The exception thrown when a null reference is passed to a method that does not accept it as a valid argument.Let us see an example.When we set a null parameter to int.Parse() method, then ArgumentNullException is thrown as shown below −Exampleusing System; class Demo { static void Main() { string val = null; int res = int.Parse(val); // error is thrown } }OutputThe following error is thrown when the above program is compiled since we have passed a null value.Unhandled Exception: System.ArgumentNullException: Value cannot be null.
To convert an Int32 value to a decimal, use the Convert.ToDecimal() method.Int32 represents a 32-bit signed integer.Let’s say the following is our Int32 value.int val = 2923;Now to convert it to decimal.decimal decVal = Convert.ToDecimal(val);Let us see the complete example.Example Live Demousing System; public class Demo { public static void Main() { int val = 2923; decimal decVal = Convert.ToDecimal(val); Console.WriteLine("Converted Int32 {0} to decimal {1:N2} value ", val, decVal); } }OutputConverted Int32 2923 to decimal 2,923.00 value