numerics in dotnet

.NET Core supports the quality numeric integral and floating-point primitives. It additionally supports the following types −

  • System.Numerics.BigInteger which is an integral type with no upper or lower bound.
  • System.Numerics.Complex is a type that represents complex numbers.
  • A set of Single Instruction Multiple Data (SIMD)-enabled vector types in the System.Numerics namespace.

Integral types

Dot NET  supports each signed and unsigned integers of various ranges from one byte to eight bytes in length. All integers are value types.

Type Signed/ Unsigned Size (bytes) Minimum Value Maximum Value
Byte Unsigned 1 0 255
Int16 Signed 2 −32,768 32,767
Int32 Signed 4 −2,147,483,648 2,147,483,647
Int64 Signed 8 −9,223,372,036,854,775,808 9,223,372,036,854,775,807
SByte Signed 1 -128 127
UInt16 Unsigned 2 0 65,535
UInt32 Unsigned 4 0 4,294,967,295
UInt64 Unsigned 8 0 18,446,744,073,709,551,615

Floating-point types

Dot NET  add three primitive floating point types, which are shown in the below table.

Type Size (bytes) Minimum Value Maximum Value
Double 8 −1.79769313486232e308 1.79769313486232e308
Single 4 −3.402823e38 3.402823e38
Decimal 16 −79,228,162,514,264,337,593,5 43,950,335 79,228,162,514,264,337,593,543,9 50,335

Related posts