Difference between Int64 and UInt64 in C#

Difference between Int64 and UInt64 in C#

C# Int64 and UInt64 Differences: Here, we will find out about the contrasts between C# Int64 and C# UInt64 information types.

C# Int64 and C# UInt64

In C#, Int64 known as a marked number of 8 bytes which can store the two sorts of qualities including negative and positive between the scopes of – 9223372036854775808 to +9223372036854775807.

UInt64 known as an unsigned whole number of 8 bytes which can store just positive qualities between the scopes of 0 to 18446744073709551615.

Contrasts somewhere in the range of ‘Int64’ and ‘UInt64’

Int64UInt64
Int64 stands for signed integer.UInt64 stands for an unsigned integer.
It’s the capacity to store the value is -9223372036854775808 to +9223372036854775807.Its the capacity to store the value is 0 to 18446744073709551615.
It can store negative and positive integers.It can store only positive integers.
It occupies 8-bytes space in the memory.It also occupies 8-bytes space in the memory.
Declaration syntax:
Int64 variable;
Declaration syntax:
UInt64 variable;

Example:

In this example, to clarify the contrasts somewhere in the range of Int64 and UInt64 in C#, we are printing their base and greatest qualities, we are additionally announcing two exhibits – arr1 is a marked number sort and arr2 is an unsigned whole number sort. Introducing the exhibits by comparing negative and positive qualities dependent on their ability.

using System;
using System.Text;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            //Int64 value range 
            Console.WriteLine("Int64 value capacity...");
            Console.WriteLine("Min: {0}, Max: {1}\n", Int64.MinValue, Int64.MaxValue);

            //UInt64 value range 
            Console.WriteLine("UInt64 value capacity...");
            Console.WriteLine("Min: {0}, Max: {1}\n", UInt64.MinValue, UInt64.MaxValue);

            //Int64 array
            Int64[] arr1 = { 	
				-9223372036854775808, 
				0, 
				1287822320009, 
				9223372036854700000, 
				9223372036854775807
			};
            Console.WriteLine("UInt64 array elements...");
            foreach (Int64 num in arr1)
            {
                Console.WriteLine(num);
            }
            Console.WriteLine();

            //UInt64 array
            UInt64[] arr2 = { 	
				0, 
				1239289300, 
				2399900900022, 
				18446744073709000000, 
				1844674407370955161 
			};
            Console.WriteLine("UInt64 array elements...");
            foreach (UInt64 num in arr2)
            {
                Console.WriteLine(num);
            }

            //hit ENTER to exit
            Console.ReadLine();
        }
    }
}

Output:

Int64 value capacity...
Min: -9223372036854775808, Max: 9223372036854775807

UInt64 value capacity...
Min: 0, Max: 18446744073709551615

UInt64 array elements...
-9223372036854775808
0
1287822320009
9223372036854700000
9223372036854775807

UInt64 array elements...
0
1239289300
2399900900022
18446744073709000000
1844674407370955161

Recent Posts

error: Alert: Content is protected!!