top of page

Primitive Data Types

  • Writer: Bhavya Tyagi
    Bhavya Tyagi
  • Feb 16, 2023
  • 2 min read

Updated: Feb 17, 2023

In the previous Article we got a basic overview about what Data Structures are and why they are used in programming. Also we got a brief description about the data structure categories.

In this article we are going to dive deeper into the categories and learn about them.


Types Of Primitive Data Types

There are 8 types of Primitive Data Types which are depicted below:


ree
Primitive Data Types

Now let’s get into each of the data types listed above.


Boolean: The boolean data type represents only one bit of information, either true or false, and is supposed to represent the two truth values of logic and Boolean algebra, but its size is virtual machine-dependent. Values of type Boolean are not implicitly or explicitly (via casts) converted to any other type.

Syntax: boolean boolVar;


Byte: A byte is an 8-bit signed two's complement integer. The byte data type is useful for reducing memory consumption in large arrays.

Syntax: byte b_var;


Short: A 16-bit signed two's complement integer is the short data type. In situations where memory savings are critical, use a short in place of a byte to save memory in large arrays.

Syntax: short ShortVar;


Int: It is a signed, 32-bit integer with two's complement.

Syntax: int intVar;


Long: A long has a substantial range. The long data type, which is a 64-bit two's complement integer, is helpful when an int type is unable to accommodate the required number.

Syntax: long longVar;


Float: A single-precision 32-bit IEEE 754 floating-point data type is the float. If you need to conserve memory in big arrays of floating-point integers, use a float (instead of a double).

Syntax: float floatVar;


Double: A double-precision 64-bit IEEE 754 floating-point is the double data type. This data type is typically the default option for decimal values.

Syntax: double doubleVar;


Char: A single 16-bit Unicode character is represented by the char data type.\

Syntax: char charVar;


In the next Article we will be starting with Linear Data Types covering in detail about Arrays, Linked List, Stack etc.



1 Comment


Sonia Prabhakar
Sonia Prabhakar
Feb 21, 2023

Good 👍👍

Like
bottom of page