C# Program to convert a Double value to an Int64 value

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.


 Live Demo

using 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);


Converted double 2.395121E+013 to Int64 23,951,213,000,000 value

Updated on: 23-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started