# What are the primitive Integer and Floating-Point Data Types in java

## Integer Data Types:

These data types represents integer numbers, i.e. numbers without any fractional parts or decimal points (For example, 113, -245, 0, 1056,…) Comes under this category. Integer data types are again sub divided into byte, short, int, and long types.

 Data type Memory size Min and Max values byte 1 byte(8bits) -128 to +127 short 2 bytes -32768 to + 32767 int 4 bytes -2147483648 to +2147483647 long 8 bytes -9223372036854775808 to +9223372036854775807

Memory representation of maximum and minimum values of a byte :

 If the sign bit indicates 0  ,  it is a positive number otherwise (if 1) , it is a negative number.

In the same way we can calculate the remaining  integer  data types .

Syntax:

 byte = ; short = ; int    = ; long = l;

## Floating-Point Data Types:

Floating-Point Data Types are useful to represent numbers with decimal point (Example : 3.16, 0.145, -1.278 ,…) . These are again classified as float (single precision floating point number) and double (double precision floating point number). The difference exists essentially in the number of digits, they can represent accurately after the decimal point. this accuracy is also called precision.

 Data type Memory Size Min and Max Values `float` `4 bytes` -3.4e38 to -1.4e-45 for -ve values 1.4e-45 to 3.4e38 for +ve values``` ``` `double` `8 bytes` ```-1.8e308 to -4.9e-324 for -ve values 4.9e-324 to 1.8e307 for +ve values```

note : Difference between the float and double is, float can represent up to 7 digits accurately after decimal point, whereas double can represent up to 15 digits accurately after a decimal point.

Syntax:

 float = F;double = d;

Example Code:

Execution Result :

Literal is of type long, if it ends with the letter L or l otherwise it is of type int.

A floating-point literal is of type float , if it ends with the letter F or f otherwise its type is double  and it can optionally end with the letter D or d.

 Related Posts :
 What are the primitive data types in java

 Current Tutorials Books & Pdf's to Download API Documentations Java Basics Beginning java Java SE 7 API Java SE Head First Java Sun Certified Programmer for Java(SCJP) LDAP Java Programming in 24 hours Sun Certified Web Component Developer SQL/PLSQL Servlets Study guide SQL & PL/SQL Documentation Servlets Web Services (Java) hibernate Api (4.3) Integrations Oracle SQL Study guide Spring Api (4.2) Web Services IBM LDAP Book Study guide Struts Api (1.3)