Skip to content

Commit

Permalink
Merge pull request #447 from JohnLCaron/bigint
Browse files Browse the repository at this point in the history
Add internal BigInteger copies for internal testing. 
kotlin jvm target is Java 17
  • Loading branch information
JohnLCaron authored Jan 31, 2024
2 parents 72197c5 + f7118b3 commit b73d8fc
Show file tree
Hide file tree
Showing 24 changed files with 7,888 additions and 592 deletions.
3 changes: 2 additions & 1 deletion egklib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ version = "2.0.3-SNAPSHOT"

kotlin {
jvm {
withJava()
compilations.all {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.jvmTarget = "17"
kotlinOptions.freeCompilerArgs = listOf(
"-Xexpect-actual-classes",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi,kotlinx.serialization.ExperimentalSerializationApi"
Expand Down
4,461 changes: 4,461 additions & 0 deletions egklib/src/jvmMain/java/org/cryptobiotic/bigint/BigInteger.java

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions egklib/src/jvmMain/java/org/cryptobiotic/bigint/DoubleConsts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.cryptobiotic.bigint;

public class DoubleConsts {
/**
* Don't let anyone instantiate this class.
*/
private DoubleConsts() {}

/**
* The number of logical bits in the significand of a
* {@code double} number, including the implicit bit.
*/
public static final int SIGNIFICAND_WIDTH = 53;

/**
* The exponent the smallest positive {@code double}
* subnormal value would have if it could be normalized..
*/
public static final int MIN_SUB_EXPONENT = Double.MIN_EXPONENT -
(SIGNIFICAND_WIDTH - 1);

/**
* Bias used in representing a {@code double} exponent.
*/
public static final int EXP_BIAS = 1023;

/**
* Bit mask to isolate the sign bit of a {@code double}.
*/
public static final long SIGN_BIT_MASK = 0x8000000000000000L;

/**
* Bit mask to isolate the exponent field of a
* {@code double}.
*/
public static final long EXP_BIT_MASK = 0x7FF0000000000000L;

/**
* Bit mask to isolate the significand field of a
* {@code double}.
*/
public static final long SIGNIF_BIT_MASK = 0x000FFFFFFFFFFFFFL;

static {
// verify bit masks cover all bit positions and that the bit
// masks are non-overlapping
assert(((SIGN_BIT_MASK | EXP_BIT_MASK | SIGNIF_BIT_MASK) == ~0L) &&
(((SIGN_BIT_MASK & EXP_BIT_MASK) == 0L) &&
((SIGN_BIT_MASK & SIGNIF_BIT_MASK) == 0L) &&
((EXP_BIT_MASK & SIGNIF_BIT_MASK) == 0L)));
}
}
52 changes: 52 additions & 0 deletions egklib/src/jvmMain/java/org/cryptobiotic/bigint/FloatConsts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.cryptobiotic.bigint;

public class FloatConsts {
/**
* Don't let anyone instantiate this class.
*/
private FloatConsts() {}

/**
* The number of logical bits in the significand of a
* {@code float} number, including the implicit bit.
*/
public static final int SIGNIFICAND_WIDTH = 24;

/**
* The exponent the smallest positive {@code float} subnormal
* value would have if it could be normalized.
*/
public static final int MIN_SUB_EXPONENT = Float.MIN_EXPONENT -
(SIGNIFICAND_WIDTH - 1);

/**
* Bias used in representing a {@code float} exponent.
*/
public static final int EXP_BIAS = 127;

/**
* Bit mask to isolate the sign bit of a {@code float}.
*/
public static final int SIGN_BIT_MASK = 0x80000000;

/**
* Bit mask to isolate the exponent field of a
* {@code float}.
*/
public static final int EXP_BIT_MASK = 0x7F800000;

/**
* Bit mask to isolate the significand field of a
* {@code float}.
*/
public static final int SIGNIF_BIT_MASK = 0x007FFFFF;

static {
// verify bit masks cover all bit positions and that the bit
// masks are non-overlapping
assert(((SIGN_BIT_MASK | EXP_BIT_MASK | SIGNIF_BIT_MASK) == ~0) &&
(((SIGN_BIT_MASK & EXP_BIT_MASK) == 0) &&
((SIGN_BIT_MASK & SIGNIF_BIT_MASK) == 0) &&
((EXP_BIT_MASK & SIGNIF_BIT_MASK) == 0)));
}
}
Loading

0 comments on commit b73d8fc

Please sign in to comment.