Convert Double Value to Int64 in C#

karthikeya Boyini
Updated on 23-Jun-2020 08:47:13

2K+ Views

To convert a Double value to an Int64 value, use the Convert.ToInt64() method.Int64 represents a 64-bit signed integer.Let’s say the following is our double value.double val = 23.951213e12;Now to convert it to Int64.long longVal = Convert.ToInt64(val);Let us see the complete example.Example Live Demousing System; public class Demo {    public static void Main() {       double val = 23.951213e12;       long longVal = Convert.ToInt64(val);       Console.WriteLine("Converted double {0:E} to Int64 {1:N0} value ", val, longVal);    } }OutputConverted double 2.395121E+013 to Int64 23,951,213,000,000 value

Records Present in JavaScript Cookies

Daniol Thomas
Updated on 23-Jun-2020 08:46:46

221 Views

Your server sends some data to the visitor's browser in the form of a cookie. The browser may accept the cookie. If it does, it is stored as a plain text record on the visitor's hard drive. Now, when the visitor arrives at another page on your site, the browser sends the same cookie to the server for retrieval. Once retrieved, your server knows/remembers what was stored earlier.Cookies are a plain text data record of 5 variable-length fields −Expires − The date the cookie will expire. If this is blank, the cookie will expire when the visitor quits the browser.Domain − The ... Read More

C# Hash Any Method

Arjun Thakur
Updated on 23-Jun-2020 08:46:29

9K+ Views

The Any method checks whether any of the element in a sequence satisfy a specific condition or not.If any element satisfy the condition, true is returned.Let us see an example.int[] arr = {5, 7, 10, 12, 15, 18, 20};Now, using Any() method, we will check whether any of the element in the above array is greater than 10 or not.arr.AsQueryable().All(val => val > 5);If any of the element satisfies the condition, then True is returned.Let us see the complete example.Example Live Demousing System; using System.Linq; class Demo {    static void Main() {       int[] arr = {5, 7, ... Read More

Convert Double to Integer in C#

Samual Sam
Updated on 23-Jun-2020 08:45:01

17K+ Views

To convert a Double value to an integer value, use the Convert.ToInt32() method.Int32 represents a 32-bit signed integer.Let’s say the following is our double value.double val = 21.34;Now to convert it to Int32.int res = Convert.ToInt32(val);Let us see the complete example.Example Live Demousing System; public class Demo {    public static void Main() {       double val = 21.34;       int res = Convert.ToInt32(val);       Console.WriteLine("Converted double {0} to integer {1} ", val, res);    } }OutputConverted double 21.34 to integer 21

Implicit Conversion from Byte to Decimal in C#

Ankith Reddy
Updated on 23-Jun-2020 08:44:39

452 Views

Byte represents an 8-bit unsigned integer.Implicit conversion of an 8-bit unsigned integer (Byte) to a Decimal is possible. Let us see how.Here’s our Byte value.byte val = 16;To implicitly convert, just assign the value as shown below −decimal dec; dec = val;Let us see the complete example.Example Live Demousing System; public class Demo {    public static void Main() {       byte val = 16;       decimal dec;       // implicit       dec = val;       Console.WriteLine("Decimal ="+dec);    } }OutputDecimal =16

Implicit Conversion from 32-bit Unsigned Integer (uint) to Decimal in C#

karthikeya Boyini
Updated on 23-Jun-2020 08:44:10

859 Views

Implicit conversion of a 32-bit unsigned integer (UInt) to a Decimal requires you to first declare a UInt.uint val = 342741539;Now to convert it to decimal, just assign the value.decimal dec; // implicit dec = val;Example Live Demousing System; public class Demo {    public static void Main() {       uint val = 342741539;       decimal dec;       // implicit       dec = val;       Console.WriteLine("Decimal = "+dec);    } }OutputDecimal = 342741539

Chash Average Method

George John
Updated on 23-Jun-2020 08:43:44

23K+ Views

To find the average of integers in C#, use the Queryable Average() method.Let’s say the following is our integer array.var arr = new int[] { 10, 17, 25, 30, 40, 55, 60, 70 };Now, use the Average() method to get the average of the elements.double avg = Queryable.Average(arr.AsQueryable());Example Live Demousing System; using System.Linq; class Demo {    static void Main() {       var arr = new int[] { 10, 17, 25, 30, 40, 55, 60, 70 };       double avg = Queryable.Average(arr.AsQueryable());       Console.WriteLine("Average = "+avg);    } }OutputAverage = 38.375

C# Chash Cast Method

Samual Sam
Updated on 23-Jun-2020 08:43:19

2K+ Views

To cast elements, use the Cast() method.The following is our list.List myList = new List { "Mac", "Windows", "Linux", "Solaris" };Now, cast and use the Cast() method with substring() method to display the first two letters of every string in the list.IEnumerable res = myList.AsQueryable().Cast().Select(str => str.Substring(0, 2));Let us see the complete example.Example Live Demousing System; using System.Linq; using System.Collections.Generic; class Demo {    static void Main() {       List list = new List { "keyboard", "mouse", "joystick", "monitor" };       // getting first 2 letters from every string       IEnumerable res = list.AsQueryable().Cast().Select(str => ... Read More

Force a Number to Display in Exponential Notation

Sravani S
Updated on 23-Jun-2020 08:43:16

1K+ Views

Use the toExponential() method to force a number to display in exponential notation, even if the number is in the range in which JavaScript normally uses standard notation.The following is the parameter −fractionDigits - An integer specifying the number of digits after the decimal point. Defaults to as many digits as necessary to specify the number.ExampleYou can try to run the following code to force a number to display in exponential function −           Javascript Method toExponential()                        var num=77.1234;          var ... Read More

Return String Value of Current Number

Manikanth Mani
Updated on 23-Jun-2020 08:42:43

247 Views

The toLocaleString() method returns a string value version of the current number in a format that may vary according to a browser's local settings.ExampleYou can try to run the following code to return a string value version −           JavaScript toLocaleString() Method                        var num = new Number(150.1234);          document.write( num.toLocaleString());          

Advertisements