Skip to content

Commit 1e77dcc

Browse files
committed
Floating-Point Data Types
1 parent 249577a commit 1e77dcc

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Core JAVA.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,3 +870,45 @@ Here’s a simple representation you can include:
870870

871871
---
872872

873+
---
874+
875+
# 🎯 long
876+
877+
| Feature | Value |
878+
|---------------|--------------------------|
879+
| Size | 8 bytes (64 bits) |
880+
| | (`-2⁶³`) to (`2⁶³ - 1`) |
881+
882+
## The all Data Types in above (byte, short, int, long) represent only integral values, not decimals.
883+
884+
---
885+
886+
> When working with integer values, we use `byte` for the shortest range, `short` for a larger range than `byte`, `int` for a widely used default range, and `long` for very large values.
887+
888+
**For decimal values, we use `float` for single-precision and `double` for double-precision.**
889+
890+
```
891+
Floating-Point Data Types
892+
|
893+
|
894+
---------------------------------------------------
895+
| |
896+
🎯 float 🎯 double
897+
| |
898+
| |
899+
|- 5 to 6 decimal places of precision |- 14 to 15 decimal places of precision
900+
|- Single precision |- Double precision
901+
|- Size: 4 bytes |- Size: 8 bytes
902+
|- Range: -1.7E38 to 1.7E38 |- Range: -1.7E308 to 1.7E308
903+
```
904+
905+
Example:
906+
10/3 = 3.333333333333333... (5 to 15 digits)
907+
908+
| Feature | float | double |
909+
|---|---|---|
910+
| Precision (decimal places) | 5 to 6 | 14 to 15 |
911+
| Type | Single precision | Double precision |
912+
| Size | 4 bytes | 8 bytes |
913+
| Range | -1.7E38 to 1.7E38 | -1.7E308 to 1.7E308
914+

0 commit comments

Comments
 (0)