Ben Chuanlong Du's Blog

It is never too late to learn.

Data Types in Different Programming Languages

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Data Type C C++ Rust Java Python numpy pyarrow Spark SQL SQL
8 bit integer short (16-bit) int8_t i8 short (16-bit) int (arbitrary precision) int8 TinyInt TinyInt or Decimal(3, 0) (slight larger)
16 bit integer short int16_t i16 short int (arbitrary precision) int16 SmallInt SmallInt or Decimal(5, 0) (slight larger)
32 bit integer int int32_t i32 int int (arbitrary precision) int32 Int Int or Decimal(10, 0) (slight larger)
64 bit integer long int64_t i64 long int (arbitrary precision) int64 BigInt BigInt or Decimal(18,0) (slight smaller)
Decimal(2,0) short (larger) short (laarger) i8 (larger) short int (arbitrary precision) int8 (larger) Decimal(2,0) or TinyInt (slight larger) Decimal(2,0)
Decimal(4,0) short (larger) short (laarger) i16 (larger) short int (arbitrary precision) int16 (larger) Decimal(4,0) or SmallInt (larger) Decimal(4,0)
Decimal(9,0) int (larger) int (laarger) i32 (larger) int int (arbitrary precision) int32 (larger) Decimal(9,0) or Int (larger) Decimal(9,0)
Decimal(18,0) long long (larger) long long (laarger) i64 (larger) long int (arbitrary precision) int64 (larger) Decimal(18,0) or BigInt (larger) Decimal(18,0)
32 bit float float float f32 float float (64-bit) float64 decimal(n,k) or float decimal(n,k)
64 bit float double double f64 double float float64 decimal(n,k) or double decimal(n,k)

References

Overview of Pandas Data Types

http://www-db.deis.unibo.it/courses/TW/DOCS/w3schools/sql/sql_datatypes_general.asp.html

https://spark.apache.org/docs/latest/sql-ref-datatypes.html

https://numpy.org/devdocs/user/basics.types.htmlo

https://arrow.apache.org/docs/python/generated/pyarrow.decimal128.html

Comments