Skip to content

Commit

Permalink
Add internal BigInteger copies for internal testing.
Browse files Browse the repository at this point in the history
Move all the exponentialtion classes to seperate package.
  • Loading branch information
JohnLCaron committed Jan 29, 2024
1 parent dea9310 commit 014c16d
Show file tree
Hide file tree
Showing 17 changed files with 7,018 additions and 14 deletions.
4,417 changes: 4,417 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 014c16d

Please sign in to comment.