-
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.
Update to v0.5.0 : merge pull request #11 from AntoineJT/develop
Big release : v0.5.0
- Loading branch information
Showing
15 changed files
with
164 additions
and
190 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 was deleted.
Oops, something went wrong.
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
34 changes: 34 additions & 0 deletions
34
src/main/java/com/github/antoinejt/jasc/ManifestInfos.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,34 @@ | ||
package com.github.antoinejt.jasc; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.Objects; | ||
import java.util.jar.Attributes; | ||
import java.util.jar.Manifest; | ||
|
||
public enum ManifestInfos { | ||
LAST_UPDATE("Last-Update"), | ||
VERSION("Version"); | ||
|
||
private final String value; | ||
|
||
ManifestInfos(String name) { | ||
Attributes attributes = null; | ||
try { | ||
attributes = getAttributesFromManifest(); | ||
} catch (IOException ignored) { | ||
} | ||
value = (attributes != null) ? attributes.getValue(name) : null; | ||
} | ||
|
||
private Attributes getAttributesFromManifest() throws IOException { | ||
URL resource = getClass().getClassLoader().getResource("META-INF/MANIFEST.MF"); | ||
Manifest manifest = new Manifest(Objects.requireNonNull(resource, "MANIFEST.MF doesn't exists!").openStream()); | ||
return manifest.getMainAttributes(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
} |
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
7 changes: 0 additions & 7 deletions
7
src/main/java/com/github/antoinejt/jasc/calculator/CalculatorException.java
This file was deleted.
Oops, something went wrong.
42 changes: 31 additions & 11 deletions
42
src/main/java/com/github/antoinejt/jasc/calculator/FunctionType.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 |
---|---|---|
@@ -1,15 +1,35 @@ | ||
package com.github.antoinejt.jasc.calculator; | ||
|
||
import java.util.function.Function; | ||
|
||
public enum FunctionType { | ||
SQRT, | ||
LOG10, | ||
LN, | ||
LOGB, | ||
COS, | ||
SIN, | ||
TAN, | ||
ARCCOS, | ||
ARCSIN, | ||
ARCTAN, | ||
EXP | ||
SQRT(Math::sqrt), | ||
LOG10(Math::log10), | ||
LN(Math::log), | ||
LOGB(number -> (double) computeBinaryLog(number)), | ||
COS(Math::cos), | ||
SIN(Math::sin), | ||
TAN(Math::tan), | ||
ARCCOS(Math::acos), | ||
ARCSIN(Math::asin), | ||
ARCTAN(Math::atan), | ||
EXP(Math::exp); | ||
|
||
private final Function<Float, Double> function; | ||
|
||
FunctionType(Function<Float, Double> function) { | ||
this.function = function; | ||
} | ||
|
||
private static int computeBinaryLog(float number) { | ||
// https://stackoverflow.com/questions/3305059/how-do-you-calculate-log-base-2-in-java-for-integers | ||
double logNumber = Math.log(number); | ||
double log2 = Math.log(2); | ||
|
||
return (int) (logNumber / log2 + 1e-10); | ||
} | ||
|
||
public double apply(float number) { | ||
return function.apply(number); | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
src/main/java/com/github/antoinejt/jasc/calculator/OperandException.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.