forked from eugenp/tutorials
-
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.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
32 changed files
with
587 additions
and
161 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
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
4 changes: 2 additions & 2 deletions
4
...ung/java8/UnsignedArithmeticUnitTest.java → ...ung/java8/UnsignedArithmeticUnitTest.java
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,10 @@ | ||
|
||
### Relevant articles: | ||
|
||
- [Calculating Logarithms in Java](https://www.baeldung.com/java-logarithms) | ||
- [Finding Greatest Common Divisor in Java](https://www.baeldung.com/java-greatest-common-divisor) | ||
- [Obtaining a Power Set of a Set in Java](https://www.baeldung.com/java-power-set-of-a-set) | ||
- [Basic Calculator in Java](https://www.baeldung.com/java-basic-calculator) | ||
- [Java 8 Math New Methods](https://www.baeldung.com/java-8-math) | ||
- More articles: [[<-- Prev]](/core-java-modules/core-java-lang-math-4) | ||
|
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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>core-java-lang-math-5</artifactId> | ||
<name>core-java-lang-math-5</name> | ||
|
||
<parent> | ||
<groupId>com.baeldung.core-java-modules</groupId> | ||
<artifactId>core-java-modules</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
</project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
4 changes: 2 additions & 2 deletions
4
...rithms/gcd/GCDImplementationUnitTest.java → ...rithms/gcd/GCDImplementationUnitTest.java
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
File renamed without changes.
175 changes: 175 additions & 0 deletions
175
core-java-modules/core-java-lang-math-5/src/test/java/com/baeldung/math/MathUnitTest.java
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,175 @@ | ||
package com.baeldung.math; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class MathUnitTest { | ||
|
||
@Test | ||
public void whenAbsInteger_thenReturnAbsoluteValue() { | ||
assertEquals(5,Math.abs(-5)); | ||
} | ||
|
||
@Test | ||
public void whenMaxBetweenTwoValue_thenReturnMaximum() { | ||
assertEquals(10, Math.max(5,10)); | ||
} | ||
|
||
@Test | ||
public void whenMinBetweenTwoValue_thenReturnMinimum() { | ||
assertEquals(5, Math.min(5,10)); | ||
} | ||
|
||
@Test | ||
public void whenSignumWithNegativeNumber_thenReturnMinusOne() { | ||
assertEquals(-1, Math.signum(-5), 0); | ||
} | ||
|
||
@Test | ||
public void whenCopySignWithNegativeSign_thenReturnNegativeArgument() { | ||
assertEquals(-5, Math.copySign(5,-1), 0); | ||
} | ||
|
||
@Test | ||
public void whenPow_thenReturnPoweredValue() { | ||
assertEquals(25, Math.pow(5,2),0); | ||
} | ||
|
||
@Test | ||
public void whenSqrt_thenReturnSquareRoot() { | ||
assertEquals(5, Math.sqrt(25),0); | ||
} | ||
|
||
@Test | ||
public void whenCbrt_thenReturnCubeRoot() { | ||
assertEquals(5, Math.cbrt(125),0); | ||
} | ||
|
||
@Test | ||
public void whenExp_thenReturnEulerNumberRaised() { | ||
assertEquals(2.718, Math.exp(1),0.1); | ||
} | ||
|
||
@Test | ||
public void whenExpm1_thenReturnEulerNumberMinusOne() { | ||
assertEquals(1.718, Math.expm1(1),0.1); | ||
} | ||
|
||
@Test | ||
public void whenGetExponent_thenReturnUnbiasedExponent() { | ||
assertEquals(8, Math.getExponent(333.3),0); | ||
assertEquals(7, Math.getExponent(222.2f),0); | ||
} | ||
|
||
@Test | ||
public void whenLog_thenReturnValue() { | ||
assertEquals(1, Math.log(Math.E),0); | ||
} | ||
|
||
@Test | ||
public void whenLog10_thenReturnValue() { | ||
assertEquals(1, Math.log10(10),0); | ||
} | ||
|
||
@Test | ||
public void whenLog1p_thenReturnValue() { | ||
assertEquals(1.31, Math.log1p(Math.E),0.1); | ||
} | ||
|
||
@Test | ||
public void whenSin_thenReturnValue() { | ||
assertEquals(1, Math.sin(Math.PI/2),0); | ||
} | ||
|
||
@Test | ||
public void whenCos_thenReturnValue() { | ||
assertEquals(1, Math.cos(0),0); | ||
} | ||
|
||
@Test | ||
public void whenTan_thenReturnValue() { | ||
assertEquals(1, Math.tan(Math.PI/4),0.1); | ||
} | ||
|
||
@Test | ||
public void whenAsin_thenReturnValue() { | ||
assertEquals(Math.PI/2, Math.asin(1),0); | ||
} | ||
|
||
@Test | ||
public void whenAcos_thenReturnValue() { | ||
assertEquals(Math.PI/2, Math.acos(0),0); | ||
} | ||
|
||
@Test | ||
public void whenAtan_thenReturnValue() { | ||
assertEquals(Math.PI/4, Math.atan(1),0); | ||
} | ||
|
||
@Test | ||
public void whenAtan2_thenReturnValue() { | ||
assertEquals(Math.PI/4, Math.atan2(1,1),0); | ||
} | ||
|
||
@Test | ||
public void whenToDegrees_thenReturnValue() { | ||
assertEquals(180, Math.toDegrees(Math.PI),0); | ||
} | ||
|
||
@Test | ||
public void whenToRadians_thenReturnValue() { | ||
assertEquals(Math.PI, Math.toRadians(180),0); | ||
} | ||
|
||
@Test | ||
public void whenCeil_thenReturnValue() { | ||
assertEquals(4, Math.ceil(Math.PI),0); | ||
} | ||
|
||
@Test | ||
public void whenFloor_thenReturnValue() { | ||
assertEquals(3, Math.floor(Math.PI),0); | ||
} | ||
|
||
@Test | ||
public void whenGetExponent_thenReturnValue() { | ||
assertEquals(8, Math.getExponent(333.3),0); | ||
} | ||
|
||
@Test | ||
public void whenIEEERemainder_thenReturnValue() { | ||
assertEquals(1.0, Math.IEEEremainder(5,2),0); | ||
} | ||
|
||
@Test | ||
public void whenNextAfter_thenReturnValue() { | ||
assertEquals(1.9499999284744263, Math.nextAfter(1.95f,1),0.0000001); | ||
} | ||
|
||
@Test | ||
public void whenNextUp_thenReturnValue() { | ||
assertEquals(1.9500002, Math.nextUp(1.95f),0.0000001); | ||
} | ||
|
||
@Test | ||
public void whenRint_thenReturnValue() { | ||
assertEquals(2.0, Math.rint(1.95f),0.0); | ||
} | ||
|
||
@Test | ||
public void whenRound_thenReturnValue() { | ||
assertEquals(2.0, Math.round(1.95f),0.0); | ||
} | ||
|
||
@Test | ||
public void whenScalb_thenReturnValue() { | ||
assertEquals(48, Math.scalb(3, 4),0.0); | ||
} | ||
|
||
@Test | ||
public void whenHypot_thenReturnValue() { | ||
assertEquals(5, Math.hypot(4, 3),0.0); | ||
} | ||
|
||
} |
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
Oops, something went wrong.