-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for various operation with double
- Loading branch information
1 parent
93a4736
commit 6e3f1c1
Showing
4 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package samples.arithmetics.operations.doubles; | ||
|
||
public class DoubleOperations { | ||
public static void main(String[] args) { | ||
// Large and small values | ||
double large = 1.989e30; // Mass of the Sun (kg) | ||
double small = 1.8549e-43; // Planck time (s) | ||
double tiny = 5e-324; // Smallest positive double | ||
double huge = 1.7e308; // Largest double | ||
|
||
// Arithmetic operations | ||
double sum = large + huge; // Addition with large numbers | ||
double diff = huge - large; // Subtraction with large numbers | ||
double product = small * tiny; // Multiplication with small numbers | ||
double quotient = huge / large; // Division with large numbers | ||
double remainder = huge % large; // Modulus operation | ||
|
||
|
||
// Special cases | ||
double underflow = small / large; // Underflow: tiny result | ||
double overflow = huge * huge; // Overflow: exceeds max double | ||
double nan = 0.0 / 0.0; // NaN (Not a Number) | ||
|
||
double result = sum/1e100 + diff/1e100 + product + quotient + remainder + underflow + | ||
(overflow == Double.POSITIVE_INFINITY ? 1e278 : 0) + | ||
(Double.isNaN(nan) ? 1e278 : 0); | ||
} | ||
} |
Binary file added
BIN
+742 Bytes
tests/test_data/samples/arithmetics/operations/doubles/DoubleOperations.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters