FC18: Added raw impl of 144 bit numbers
This commit is contained in:
parent
d41af20079
commit
46d305b5aa
9 changed files with 345 additions and 106 deletions
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
package org.x4o.fc18;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -253,31 +252,44 @@ public class FourCornerUnicodeDisplay {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void strobeNumberDozeger(BigInteger value) {
|
||||
public void strobeNumberINT144(BigInteger value) {
|
||||
List<Integer> numberCandy = new ArrayList<>();
|
||||
FourCornerRecipe.toDecimalsX18(numberCandy, value);
|
||||
renderFromInt18(numberCandy, output);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void strobeNumberDozimal(BigDecimal value) {
|
||||
public void strobeNumberDEC144(BigInteger coefficient, int exponent) {
|
||||
List<Integer> numberCandy = new ArrayList<>();
|
||||
FourCornerRecipe.toDecimalsX18(numberCandy, value.unscaledValue());
|
||||
numberCandy.add(FCDotCDC1604DashP6.NY18_ASTERISK.ordinal());
|
||||
numberCandy.add(FCDotCDC1604DashP6.NX16_P.ordinal());
|
||||
numberCandy.add(FCDotCDC1604DashP6.NX15_O.ordinal());
|
||||
numberCandy.add(FCDotCDC1604DashP6.NX23_W.ordinal());
|
||||
numberCandy.add(FCDotCDC1604DashP6.NY25_ROUND_LEFT.ordinal());
|
||||
FourCornerRecipe.toDecimalsX18(numberCandy, coefficient);
|
||||
numberCandy.add(FCDotCDC1604DashP6.NY18_ASTERISK.ordinal());
|
||||
FourCornerRecipe.toDecimalsX18(numberCandy, 1);
|
||||
FourCornerRecipe.toDecimalsX18(numberCandy, 0);
|
||||
FourCornerRecipe.toDecimalsX18(numberCandy, value.scale());
|
||||
numberCandy.add(FCDotCDC1604DashP6.NY24_ROUND_RIGHT.ordinal());
|
||||
FourCornerRecipe.toScriptSuperX18(numberCandy, exponent);
|
||||
renderFromInt18(numberCandy, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void strobeNCR1632(BigInteger numerator, BigInteger denominator) {
|
||||
public void strobeNumberFP144(boolean sign, int exponent, BigInteger significand) {
|
||||
List<Integer> numberCandy = new ArrayList<>();
|
||||
numberCandy.add(FCDotCDC1604DashP6.NY25_ROUND_LEFT.ordinal());
|
||||
numberCandy.add(FCDotCDC1604DashP6.NY19_MINUS.ordinal());
|
||||
FourCornerRecipe.toDecimalsX18(numberCandy, 1);
|
||||
numberCandy.add(FCDotCDC1604DashP6.NY24_ROUND_RIGHT.ordinal());
|
||||
FourCornerRecipe.toScriptSuperX18(numberCandy, sign?1:0);
|
||||
numberCandy.add(FCDotCDC1604DashP6.NY18_ASTERISK.ordinal());
|
||||
FourCornerRecipe.toDecimalsX18(numberCandy, 2);
|
||||
FourCornerRecipe.toScriptSuperX18(numberCandy, exponent);
|
||||
FourCornerRecipe.toScriptSuperX18(numberCandy, -127);
|
||||
numberCandy.add(FCDotCDC1604DashP6.NY18_ASTERISK.ordinal());
|
||||
FourCornerRecipe.toDecimalsX18(numberCandy, 1);
|
||||
numberCandy.add(FCDotCDC1604DashP6.NY16_DOT.ordinal());
|
||||
FourCornerRecipe.toDecimalsX18(numberCandy, significand);
|
||||
renderFromInt18(numberCandy, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void strobeNumberNCR1632(BigInteger numerator, BigInteger denominator) {
|
||||
List<Integer> math = new ArrayList<>();
|
||||
FourCornerRecipe.toScriptSuperX18(math, numerator);
|
||||
math.add(FCDotCDC1604DashP6.NY02_BAR_V_RIGHT.ordinal());
|
||||
|
|
|
|||
|
|
@ -308,13 +308,17 @@ public enum FourCornerDotCake {
|
|||
FC_CLK1K_Y(131072 + (1024*24), 1024, FCDotCLK1KDashY.values()),
|
||||
FC_CLK1K_Z(131072 + (1024*25), 1024, FCDotCLK1KDashZ.values()),
|
||||
|
||||
// =========== Define document structures and sandworms
|
||||
// =========== Define digital numbers and document structures and sandworms
|
||||
|
||||
FC_DOZEGER_192(0x026800, 512, "Dozeger 192 bit integer"),
|
||||
FC_DOZIMAL_192(0x026A00, 512, "Dozimal 192 bit decimal"),
|
||||
/// Number signed 144 bit integer
|
||||
FC_NUM_INT144(0x026800, 384, "Number of 144 bit integer"),
|
||||
/// Number signed 144 bit base 10 decimal
|
||||
FC_NUM_DEC144(0x026980, 384, "Number of 144 bit base 10 decimal"),
|
||||
/// Number signed 144 bit base 2 float
|
||||
FC_NUM_FP144(0x026B00, 384, "Number of 144 bit base 2 float"),
|
||||
|
||||
/// Reserved Flag4 Structures
|
||||
__RESERVED_F4(0x026C00, 0x026DBE - 0x026C00, "Reserved for F4 structures"),
|
||||
__RESERVED_F4(0x026C80, 0x026DBE - 0x026C80, "Reserved for F4 structures"),
|
||||
|
||||
/// Tele Type Ytructure00 zero one Nether Line
|
||||
FC_F4TTY0001_NL(0x026DBE, 1, FCDotF4TTY0001DashNL.values(), "Flag4 TTY00 zero one Nether Line"),
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
package org.x4o.fc18.zion7;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -43,22 +42,25 @@ public interface FourCornerZion7Candlelier extends FourCornerZion7AlphaOmega {
|
|||
/// Block of one of more number grams of given base.
|
||||
void strobeNumberGrams(FourCornerZion7NumberGram gram, List<Integer> values);
|
||||
|
||||
/// Embed signed integer up to 192 bit
|
||||
void strobeNumberDozeger(BigInteger value);
|
||||
|
||||
/// Embed signed decimal up to 192 bit
|
||||
void strobeNumberDozimal(BigDecimal value);
|
||||
/// Embedded signed integer up to 144 bit.
|
||||
void strobeNumberINT144(BigInteger value);
|
||||
|
||||
/// 1152 bit fractions of two 576 bit numbers.
|
||||
void strobeNCR1632(BigInteger numerator, BigInteger denominator);
|
||||
/// Embedded signed decimal up to 144 bit. (s126+s18)
|
||||
void strobeNumberDEC144(BigInteger coefficient, int exponent);
|
||||
|
||||
/// Octal sand walker, with an 72 to 576 bit mime-type rhythm header.
|
||||
/// Embedded signed float up to 144 bit. (u1+u17+u126)
|
||||
void strobeNumberFP144(boolean sign, int exponent, BigInteger significand);
|
||||
|
||||
/// Embedded signed fractions up to 1152 bit of two 576 bit numbers.
|
||||
void strobeNumberNCR1632(BigInteger numerator, BigInteger denominator);
|
||||
|
||||
/// Embedded sand walker, with an 72 to 576 bit mime-type rhythm header.
|
||||
void strobeSandWalker(List<PrimordialOctal> rhythm);
|
||||
|
||||
/// Octal sand worm spice
|
||||
/// Embedded sand worm spice.
|
||||
void strobeSandWorm(List<PrimordialOctal> spice);
|
||||
|
||||
/// Handles the lexer salah sequence strobes
|
||||
/// The external supported salah sequence strobes.
|
||||
void strobeSalahSequence(FourCornerZion7SalahSequence type, List<List<Integer>> arguments);
|
||||
|
||||
interface Adapter extends FourCornerZion7Candlelier, FourCornerZion7AlphaOmega.Adapter {
|
||||
|
|
@ -76,15 +78,19 @@ public interface FourCornerZion7Candlelier extends FourCornerZion7AlphaOmega {
|
|||
}
|
||||
|
||||
@Override
|
||||
default void strobeNumberDozeger(BigInteger value) {
|
||||
default void strobeNumberINT144(BigInteger value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void strobeNumberDozimal(BigDecimal value) {
|
||||
default void strobeNumberDEC144(BigInteger coefficient, int exponent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void strobeNCR1632(BigInteger numerator, BigInteger denominator) {
|
||||
default void strobeNumberFP144(boolean sign, int exponent, BigInteger significand) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void strobeNumberNCR1632(BigInteger numerator, BigInteger denominator) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -31,8 +31,14 @@ import java.util.List;
|
|||
/// @version 1.0 Aug 24, 2025
|
||||
public final class FourCornerZion7Petroglyphs {
|
||||
|
||||
public static final BigInteger DOZEGER192_MASK_PAGE = BigInteger.valueOf(0b111);
|
||||
public static final BigInteger DOZEGER192_VALUE_MAX = new BigInteger("7FFFFFFFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFFFFFFFF", 16);
|
||||
public static final int OCTAL_MASK_INT = 0b111;
|
||||
public static final BigInteger OCTAL_MASK_BIG = BigInteger.valueOf(OCTAL_MASK_INT);
|
||||
|
||||
public static final BigInteger INT144_VALUE_MAX = new BigInteger("7FFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16);
|
||||
public static final BigInteger DEC144_COEFFICIENT_MAX = new BigInteger("3FFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFF", 16);
|
||||
public static final int DEC144_EXPONENT_MAX = 0x1FFFF;
|
||||
public static final BigInteger FP144_SIGNIFICAND_MAX = DEC144_COEFFICIENT_MAX;
|
||||
public static final int FP144_EXPONENT_MAX = 0x1FFFF;
|
||||
|
||||
public static final BigInteger NCR1632_MASK_PAGE = BigInteger.valueOf(0x1FF);
|
||||
public static final BigInteger NCR1632_VALUE_MAX = new BigInteger("7FFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16);
|
||||
|
|
|
|||
|
|
@ -161,10 +161,10 @@ public class FourCornerZionStenoGrapher {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void strobeNumberDozeger(BigInteger value) {
|
||||
public void strobeNumberINT144(BigInteger value) {
|
||||
Objects.requireNonNull(value);
|
||||
if (value.compareTo(FourCornerZion7Petroglyphs.DOZEGER192_VALUE_MAX) > 0) {
|
||||
throw new IllegalArgumentException("Value dozeger is larger than 192 bit: " + value);
|
||||
if (value.compareTo(FourCornerZion7Petroglyphs.INT144_VALUE_MAX) > 0) {
|
||||
throw new IllegalArgumentException("INT144 value is larger than 144 bit: " + value);
|
||||
}
|
||||
BigInteger valuePos = value;
|
||||
boolean negative = false;
|
||||
|
|
@ -172,27 +172,97 @@ public class FourCornerZionStenoGrapher {
|
|||
valuePos = value.negate();
|
||||
negative = true;
|
||||
}
|
||||
for (int i = 63; i >= 0; i--) {
|
||||
int bankValue = valuePos.shiftRight(i * 3).and(FourCornerZion7Petroglyphs.DOZEGER192_MASK_PAGE).intValue();
|
||||
if (i == 63 && negative) {
|
||||
for (int i = 47; i >= 0; i--) {
|
||||
int bankValue = valuePos.shiftRight(i * 3).and(FourCornerZion7Petroglyphs.OCTAL_MASK_BIG).intValue();
|
||||
if (i == 47 && negative) {
|
||||
bankValue = (bankValue & 0b011) + 4;
|
||||
}
|
||||
if (bankValue == 0 && i > 0) {
|
||||
continue;
|
||||
}
|
||||
int cakePoint = FourCornerDotCake.FC_DOZEGER_192.getStart() + bankValue + (i * 8);
|
||||
outAdd(cakePoint);
|
||||
outAdd(FourCornerDotCake.FC_NUM_INT144.getStart() + bankValue + (i * 8));
|
||||
}
|
||||
outFlush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void strobeNumberDozimal(BigDecimal value) {
|
||||
Objects.requireNonNull(value);
|
||||
public void strobeNumberDEC144(BigInteger coefficient, int exponent) {
|
||||
Objects.requireNonNull(coefficient);
|
||||
if (coefficient.compareTo(FourCornerZion7Petroglyphs.DEC144_COEFFICIENT_MAX) > 0) {
|
||||
throw new IllegalArgumentException("DEC144 coefficient is larger than 126 bit: " + coefficient);
|
||||
}
|
||||
if (exponent > FourCornerZion7Petroglyphs.DEC144_EXPONENT_MAX) {
|
||||
throw new IllegalArgumentException("DEC144 exponent is larger than 17 bit: " + exponent);
|
||||
}
|
||||
BigInteger valuePos = coefficient;
|
||||
boolean negative = false;
|
||||
if (coefficient.signum() == -1) {
|
||||
valuePos = coefficient.negate();
|
||||
negative = true;
|
||||
}
|
||||
for (int i = 47; i >= 6; i--) {
|
||||
int bankValue = valuePos.shiftRight((i-6) * 3).and(FourCornerZion7Petroglyphs.OCTAL_MASK_BIG).intValue();
|
||||
if (i == 47 /*&& negative*/) {
|
||||
bankValue = (bankValue & 0b011) + (negative?4:0); // TODO check if max value....
|
||||
}
|
||||
if (bankValue == 0) {
|
||||
continue;
|
||||
}
|
||||
outAdd(FourCornerDotCake.FC_NUM_DEC144.getStart() + bankValue + (i * 8));
|
||||
}
|
||||
int exponentPos = exponent;
|
||||
negative = exponent < 0;
|
||||
if (negative) {
|
||||
exponentPos = 0 - exponent;
|
||||
}
|
||||
for (int i = 5; i >= 0; i--) {
|
||||
int bankValue = (exponentPos >> (i * 3)) & FourCornerZion7Petroglyphs.OCTAL_MASK_INT;
|
||||
if (i == 5 && negative) {
|
||||
bankValue = (bankValue & 0b011) + 4;
|
||||
}
|
||||
if (bankValue == 0 && i > 0) {
|
||||
continue;
|
||||
}
|
||||
outAdd(FourCornerDotCake.FC_NUM_DEC144.getStart() + bankValue + (i * 8));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void strobeNCR1632(BigInteger numerator, BigInteger denominator) {
|
||||
public void strobeNumberFP144(boolean sign, int exponent, BigInteger significand) {
|
||||
Objects.requireNonNull(significand);
|
||||
if (significand.compareTo(FourCornerZion7Petroglyphs.FP144_SIGNIFICAND_MAX) > 0) {
|
||||
throw new IllegalArgumentException("FP144 significand is larger than 126 bit: " + significand);
|
||||
}
|
||||
if (significand.signum() == -1) {
|
||||
throw new IllegalArgumentException("FP144 significand is smaller than zero: " + significand);
|
||||
}
|
||||
if (exponent > FourCornerZion7Petroglyphs.FP144_EXPONENT_MAX) {
|
||||
throw new IllegalArgumentException("FP144 exponent is larger than 17 bit: " + exponent);
|
||||
}
|
||||
if (exponent < 0) {
|
||||
throw new IllegalArgumentException("FP144 exponent is smaller than zero: " + exponent);
|
||||
}
|
||||
for (int i = 47; i >= 42; i--) {
|
||||
int bankValue = (exponent >> ((i-42) * 3)) & FourCornerZion7Petroglyphs.OCTAL_MASK_INT;
|
||||
if (i == 47 && sign) {
|
||||
bankValue = (bankValue & 0b011) + 4;
|
||||
}
|
||||
if (bankValue == 0) {
|
||||
continue;
|
||||
}
|
||||
outAdd(FourCornerDotCake.FC_NUM_FP144.getStart() + bankValue + (i * 8));
|
||||
}
|
||||
for (int i = 41; i >= 0; i--) {
|
||||
int bankValue = significand.shiftRight(i * 3).and(FourCornerZion7Petroglyphs.OCTAL_MASK_BIG).intValue();
|
||||
if (bankValue == 0 && i > 0) {
|
||||
continue;
|
||||
}
|
||||
outAdd(FourCornerDotCake.FC_NUM_FP144.getStart() + bankValue + (i * 8));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void strobeNumberNCR1632(BigInteger numerator, BigInteger denominator) {
|
||||
Objects.requireNonNull(numerator);
|
||||
Objects.requireNonNull(denominator);
|
||||
if (denominator.equals(BigInteger.ZERO)) { // 0/1 = zero but 1/0 is NaN
|
||||
|
|
@ -294,8 +364,7 @@ public class FourCornerZionStenoGrapher {
|
|||
if (bankValue == 0 && i > 0) {
|
||||
continue;
|
||||
}
|
||||
int cakePoint = FourCornerDotCake.FC_NCR1632_NUM.getStart() + bankValue + (i * 512);
|
||||
outAdd(cakePoint);
|
||||
outAdd(FourCornerDotCake.FC_NCR1632_NUM.getStart() + bankValue + (i * 512));
|
||||
}
|
||||
for (int i = 63; i >= 0; i--) {
|
||||
int bankValue = denominatorPos.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue();
|
||||
|
|
@ -305,8 +374,7 @@ public class FourCornerZionStenoGrapher {
|
|||
if (bankValue == 0 && i > 0) {
|
||||
continue;
|
||||
}
|
||||
int cakePoint = FourCornerDotCake.FC_NCR1632_DEN.getStart() + bankValue + (i * 512);
|
||||
outAdd(cakePoint);
|
||||
outAdd(FourCornerDotCake.FC_NCR1632_DEN.getStart() + bankValue + (i * 512));
|
||||
}
|
||||
outFlush();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,10 +87,13 @@ public class FourCornerZionStenoLexer {
|
|||
if (FourCornerDotCake.FC_SANDWORM_15.equals(cakeSlice)) {
|
||||
continue; // parse nether body manually
|
||||
}
|
||||
if (FourCornerDotCake.FC_DOZEGER_192.equals(cakeSlice)) {
|
||||
if (FourCornerDotCake.FC_NUM_INT144.equals(cakeSlice)) {
|
||||
continue; // parse block manually
|
||||
}
|
||||
if (FourCornerDotCake.FC_DOZIMAL_192.equals(cakeSlice)) {
|
||||
if (FourCornerDotCake.FC_NUM_DEC144.equals(cakeSlice)) {
|
||||
continue; // parse block manually
|
||||
}
|
||||
if (FourCornerDotCake.FC_NUM_FP144.equals(cakeSlice)) {
|
||||
continue; // parse block manually
|
||||
}
|
||||
if (FourCornerDotCake.FC_NCR1632_DEN.equals(cakeSlice)) {
|
||||
|
|
@ -106,7 +109,9 @@ public class FourCornerZionStenoLexer {
|
|||
CAKE_SLICE_EATERS.add(new StenoScannerWordCakeSlice(cakeSlice));
|
||||
}
|
||||
CAKE_SLICE_EATERS.add(new StenoScannerCDCDEC());
|
||||
CAKE_SLICE_EATERS.add(new StenoScannerDozeger());
|
||||
CAKE_SLICE_EATERS.add(new StenoScannerNumINT144());
|
||||
CAKE_SLICE_EATERS.add(new StenoScannerNumDEC144());
|
||||
CAKE_SLICE_EATERS.add(new StenoScannerNumFP144());
|
||||
CAKE_SLICE_EATERS.add(new StenoScannerNCR18());
|
||||
CAKE_SLICE_EATERS.add(new StenoScannerSandWorm());
|
||||
ArrayList.class.cast(CAKE_SLICE_EATERS).trimToSize();
|
||||
|
|
@ -223,7 +228,7 @@ public class FourCornerZionStenoLexer {
|
|||
if (denominatorNegetive) {
|
||||
denominator = denominator.negate();
|
||||
}
|
||||
handler.strobeNCR1632(numerator, denominator);
|
||||
handler.strobeNumberNCR1632(numerator, denominator);
|
||||
// reset the bank after each fire
|
||||
for (int i = 0; i < numeratorBank.length; i++) {
|
||||
numeratorBank[i] = 0;
|
||||
|
|
@ -291,20 +296,12 @@ public class FourCornerZionStenoLexer {
|
|||
|
||||
static class StenoScannerWordCakeSlice extends StenoScanner {
|
||||
|
||||
//private final FourCornerDotCake cakeSlice;
|
||||
|
||||
public StenoScannerWordCakeSlice(FourCornerDotCake cakeSlice) {
|
||||
super(cakeSlice);
|
||||
//this.cakeSlice = Objects.requireNonNull(cakeSlice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FourCornerZionStenoLexer lexer, int idxFirst, int idxLast) {
|
||||
// List<Integer> offsets = new ArrayList<>();
|
||||
// for (int i = idxFirst; i <= idxLast; i++) {
|
||||
// offsets.add(lexer.input.get(i) - blockStart);
|
||||
// }
|
||||
// lexer.handler.strobeWords(cakeSlice, offsets);
|
||||
lexer.handler.strobeWords(lexer.input.subList(idxFirst, idxLast + 1));
|
||||
}
|
||||
}
|
||||
|
|
@ -336,10 +333,6 @@ public class FourCornerZionStenoLexer {
|
|||
|
||||
@Override
|
||||
public void process(FourCornerZionStenoLexer lexer, int idxFirst, int idxLast) {
|
||||
//List<Integer> wormBody15 = new ArrayList<>();
|
||||
//for (int i = idxFirst; i <= idxLast; i++) {
|
||||
// wormBody15.add(lexer.input.get(i));
|
||||
//}
|
||||
List<Integer> wormBody15 = lexer.input.subList(idxFirst, idxLast + 1);
|
||||
List<PrimordialOctal> wormSpice = new ArrayList<>();
|
||||
Iterator<Integer> i15 = wormBody15.iterator();
|
||||
|
|
@ -375,32 +368,32 @@ public class FourCornerZionStenoLexer {
|
|||
}
|
||||
}
|
||||
|
||||
static class StenoScannerDozeger extends StenoScanner {
|
||||
static class StenoScannerNumINT144 extends StenoScanner {
|
||||
|
||||
static private final int CAKEPOINT_BANK0_END = FourCornerDotCake.FC_DOZEGER_192.getStart() + 8;
|
||||
static private final int CAKEPOINT_BANK0_END = FourCornerDotCake.FC_NUM_INT144.getStart() + 8;
|
||||
|
||||
public StenoScannerDozeger() {
|
||||
super(FourCornerDotCake.FC_DOZEGER_192);
|
||||
public StenoScannerNumINT144() {
|
||||
super(FourCornerDotCake.FC_NUM_INT144);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FourCornerZionStenoLexer lexer, int idxFirst, int idxLast) {
|
||||
int valueBank[] = new int[64];
|
||||
int valueBank[] = new int[48];
|
||||
boolean negetive = false;
|
||||
boolean missingSparkler = true;
|
||||
for (int i = idxFirst; i <= idxLast; i++) {
|
||||
int cakePoint = lexer.input.get(i);
|
||||
int valueOffset = cakePoint - FourCornerDotCake.FC_DOZEGER_192.getStart();
|
||||
int valueOffset = cakePoint - FourCornerDotCake.FC_NUM_INT144.getStart();
|
||||
int bankSelect = valueOffset / 8;
|
||||
int bankValue = valueOffset % 8;
|
||||
if (bankSelect == 63 && (bankValue & 0b100) == 4) {
|
||||
if (bankSelect == 47 && (bankValue & 0b100) == 4) {
|
||||
negetive = true;
|
||||
bankValue = bankValue & 0b011; // remove sign bit from value
|
||||
bankValue = bankValue & 0b011;
|
||||
}
|
||||
valueBank[bankSelect] = bankValue;
|
||||
if (cakePoint > CAKEPOINT_BANK0_END) {
|
||||
missingSparkler = true;
|
||||
continue; // Only fire value on lowest value select
|
||||
continue;
|
||||
}
|
||||
BigInteger valueNumber = BigInteger.ZERO;
|
||||
for (int ii = 0; ii < valueBank.length; ii++) {
|
||||
|
|
@ -409,14 +402,120 @@ public class FourCornerZionStenoLexer {
|
|||
if (negetive) {
|
||||
valueNumber = valueNumber.negate();
|
||||
}
|
||||
lexer.handler.strobeNumberDozeger(valueNumber);
|
||||
lexer.handler.strobeNumberINT144(valueNumber);
|
||||
for (int ii = 0; ii < valueBank.length; ii++) {
|
||||
valueBank[ii] = 0;
|
||||
}
|
||||
missingSparkler = false;
|
||||
}
|
||||
if (missingSparkler) {
|
||||
lexer.smokeSignals.burnNumberDozegerMissingSparkler(lexer.currLine, lexer.currCol);
|
||||
lexer.smokeSignals.burnNumberINT144MissingSparkler(lexer.currLine, lexer.currCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class StenoScannerNumDEC144 extends StenoScanner {
|
||||
|
||||
static private final int CAKEPOINT_BANK0_END = FourCornerDotCake.FC_NUM_DEC144.getStart() + 8;
|
||||
|
||||
public StenoScannerNumDEC144() {
|
||||
super(FourCornerDotCake.FC_NUM_DEC144);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FourCornerZionStenoLexer lexer, int idxFirst, int idxLast) {
|
||||
int valueBank[] = new int[48];
|
||||
boolean negative = false;
|
||||
boolean missingSparkler = true;
|
||||
for (int i = idxFirst; i <= idxLast; i++) {
|
||||
int cakePoint = lexer.input.get(i);
|
||||
int valueOffset = cakePoint - FourCornerDotCake.FC_NUM_DEC144.getStart();
|
||||
int bankSelect = valueOffset / 8;
|
||||
int bankValue = valueOffset % 8;
|
||||
if (bankSelect == 47 && (bankValue & 0b100) == 4) {
|
||||
negative = true;
|
||||
bankValue = bankValue & 0b011;
|
||||
}
|
||||
valueBank[bankSelect] = bankValue;
|
||||
if (cakePoint > CAKEPOINT_BANK0_END) {
|
||||
missingSparkler = true;
|
||||
continue;
|
||||
}
|
||||
int exponent = 0;
|
||||
exponent += (valueBank[5] & 0b011) << 15;
|
||||
exponent += valueBank[4] << 12;
|
||||
exponent += valueBank[3] << 9;
|
||||
exponent += valueBank[2] << 6;
|
||||
exponent += valueBank[1] << 3;
|
||||
exponent += valueBank[0] << 0;
|
||||
BigInteger valueNumber = BigInteger.ZERO;
|
||||
for (int ii = 6; ii < 48; ii++) {
|
||||
valueNumber = valueNumber.add(BigInteger.valueOf(valueBank[ii]).shiftLeft((ii-6) * 3));
|
||||
}
|
||||
if (negative) {
|
||||
valueNumber = valueNumber.negate();
|
||||
}
|
||||
if ((valueBank[5] & 0b100) == 4) {
|
||||
exponent = 0 - exponent;
|
||||
}
|
||||
lexer.handler.strobeNumberDEC144(valueNumber, exponent);
|
||||
for (int ii = 0; ii < valueBank.length; ii++) {
|
||||
valueBank[ii] = 0;
|
||||
}
|
||||
missingSparkler = false;
|
||||
}
|
||||
if (missingSparkler) {
|
||||
lexer.smokeSignals.burnNumberFP144MissingSparkler(lexer.currLine, lexer.currCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class StenoScannerNumFP144 extends StenoScanner {
|
||||
|
||||
static private final int CAKEPOINT_BANK0_END = FourCornerDotCake.FC_NUM_FP144.getStart() + 8;
|
||||
|
||||
public StenoScannerNumFP144() {
|
||||
super(FourCornerDotCake.FC_NUM_FP144);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FourCornerZionStenoLexer lexer, int idxFirst, int idxLast) {
|
||||
int valueBank[] = new int[48];
|
||||
boolean negative = false;
|
||||
boolean missingSparkler = true;
|
||||
for (int i = idxFirst; i <= idxLast; i++) {
|
||||
int cakePoint = lexer.input.get(i);
|
||||
int valueOffset = cakePoint - FourCornerDotCake.FC_NUM_FP144.getStart();
|
||||
int bankSelect = valueOffset / 8;
|
||||
int bankValue = valueOffset % 8;
|
||||
if (bankSelect == 47 && (bankValue & 0b100) == 4) {
|
||||
negative = true;
|
||||
bankValue = bankValue & 0b011;
|
||||
}
|
||||
valueBank[bankSelect] = bankValue;
|
||||
if (cakePoint > CAKEPOINT_BANK0_END) {
|
||||
missingSparkler = true;
|
||||
continue;
|
||||
}
|
||||
int exponent = 0;
|
||||
exponent += (valueBank[47] & 0b011) << 15;
|
||||
exponent += valueBank[46] << 12;
|
||||
exponent += valueBank[45] << 9;
|
||||
exponent += valueBank[44] << 6;
|
||||
exponent += valueBank[43] << 3;
|
||||
exponent += valueBank[42] << 0;
|
||||
BigInteger valueNumber = BigInteger.ZERO;
|
||||
for (int ii = 0; ii < 42; ii++) {
|
||||
valueNumber = valueNumber.add(BigInteger.valueOf(valueBank[ii]).shiftLeft(ii * 3));
|
||||
}
|
||||
lexer.handler.strobeNumberFP144(negative, exponent, valueNumber);
|
||||
for (int ii = 0; ii < valueBank.length; ii++) {
|
||||
valueBank[ii] = 0;
|
||||
}
|
||||
missingSparkler = false;
|
||||
}
|
||||
if (missingSparkler) {
|
||||
lexer.smokeSignals.burnNumberFP144MissingSparkler(lexer.currLine, lexer.currCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -451,7 +550,7 @@ public class FourCornerZionStenoLexer {
|
|||
missingSparkler = false;
|
||||
}
|
||||
if (missingSparkler) {
|
||||
lexer.smokeSignals.burnNCR1632MissingSparkler(lexer.currLine, lexer.currCol);
|
||||
lexer.smokeSignals.burnNumberNCR1632MissingSparkler(lexer.currLine, lexer.currCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,13 @@ public interface FourCornerZionStenoLexerSmoke {
|
|||
|
||||
void burnSandWalkerStepUnaligned(int line, int col, int size);
|
||||
|
||||
void burnNumberDozegerMissingSparkler(int line, int col);
|
||||
void burnNumberINT144MissingSparkler(int line, int col);
|
||||
|
||||
void burnNCR1632MissingSparkler(int line, int col);
|
||||
void burnNumberDEC144MissingSparkler(int line, int col);
|
||||
|
||||
void burnNumberFP144MissingSparkler(int line, int col);
|
||||
|
||||
void burnNumberNCR1632MissingSparkler(int line, int col);
|
||||
|
||||
interface Adapter extends FourCornerZionStenoLexerSmoke {
|
||||
|
||||
|
|
@ -73,11 +77,19 @@ public interface FourCornerZionStenoLexerSmoke {
|
|||
}
|
||||
|
||||
@Override
|
||||
default void burnNumberDozegerMissingSparkler(int line, int col) {
|
||||
default void burnNumberINT144MissingSparkler(int line, int col) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void burnNCR1632MissingSparkler(int line, int col) {
|
||||
default void burnNumberDEC144MissingSparkler(int line, int col) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void burnNumberFP144MissingSparkler(int line, int col) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void burnNumberNCR1632MissingSparkler(int line, int col) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,13 +128,23 @@ public interface FourCornerZionStenoLexerSmoke {
|
|||
}
|
||||
|
||||
@Override
|
||||
default void burnNumberDozegerMissingSparkler(int line, int col) {
|
||||
burnMonoPipe(line, col, "burnNumberDozegerMissingSparkler");
|
||||
default void burnNumberINT144MissingSparkler(int line, int col) {
|
||||
burnMonoPipe(line, col, "burnNumberINT144MissingSparkler");
|
||||
}
|
||||
|
||||
@Override
|
||||
default void burnNCR1632MissingSparkler(int line, int col) {
|
||||
burnMonoPipe(line, col, "burnNCR1632MissingSparkler");
|
||||
default void burnNumberDEC144MissingSparkler(int line, int col) {
|
||||
burnMonoPipe(line, col, "burnNumberDEC144MissingSparkler");
|
||||
}
|
||||
|
||||
@Override
|
||||
default void burnNumberFP144MissingSparkler(int line, int col) {
|
||||
burnMonoPipe(line, col, "burnNumberFP144MissingSparkler");
|
||||
}
|
||||
|
||||
@Override
|
||||
default void burnNumberNCR1632MissingSparkler(int line, int col) {
|
||||
burnMonoPipe(line, col, "burnNumberNCR1632MissingSparkler");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,15 +64,37 @@ public class StenoGrapherTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDozegerValues() throws Exception {
|
||||
public void testINT144Values() throws Exception {
|
||||
List<Integer> outX18 = new ArrayList<>();
|
||||
FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18);
|
||||
writerX18.strobeNumberDozeger(BigInteger.valueOf(123));
|
||||
writerX18.strobeNumberINT144(BigInteger.valueOf(123));
|
||||
writerX18.strobeWord(FCDotCDC1604DashP6.NY19_MINUS.ordinal());
|
||||
writerX18.strobeNumberDozeger(FourCornerZion7Petroglyphs.DOZEGER192_VALUE_MAX);
|
||||
writerX18.strobeNumberDozeger(BigInteger.valueOf(-123));
|
||||
writerX18.strobeNumberINT144(FourCornerZion7Petroglyphs.INT144_VALUE_MAX);
|
||||
writerX18.strobeNumberINT144(BigInteger.valueOf(-123));
|
||||
String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18);
|
||||
Assertions.assertEquals("123-3138550867693340381917894711603833208051177722232017256447-123", resX18);
|
||||
Assertions.assertEquals("123-11150372599265311570767859136324180752990207-123", resX18);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDEC144Values() throws Exception {
|
||||
List<Integer> outX18 = new ArrayList<>();
|
||||
FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18);
|
||||
writerX18.strobeNumberDEC144(BigInteger.valueOf(123), 456);
|
||||
writerX18.strobeWord(FCDotCDC1604DashP6.NY09_EQUALS.ordinal());
|
||||
writerX18.strobeNumberDEC144(FourCornerZion7Petroglyphs.DEC144_COEFFICIENT_MAX, FourCornerZion7Petroglyphs.DEC144_EXPONENT_MAX);
|
||||
String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18);
|
||||
Assertions.assertEquals("123*10⁴⁵⁶=42535295865117307932921825928971026431*10¹³¹⁰⁷¹", resX18);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFP144Values() throws Exception {
|
||||
List<Integer> outX18 = new ArrayList<>();
|
||||
FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18);
|
||||
writerX18.strobeNumberFP144(true, 456, BigInteger.valueOf(123));
|
||||
writerX18.strobeWord(FCDotCDC1604DashP6.NY09_EQUALS.ordinal());
|
||||
writerX18.strobeNumberFP144(false, FourCornerZion7Petroglyphs.FP144_EXPONENT_MAX, FourCornerZion7Petroglyphs.FP144_SIGNIFICAND_MAX);
|
||||
String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18);
|
||||
Assertions.assertEquals("(-1)¹*2⁴⁵⁶⁻¹²⁷*1.123=(-1)⁰*2¹³¹⁰⁷¹⁻¹²⁷*1.85070591730234615865843651857942052863", resX18);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -82,14 +104,14 @@ public class StenoGrapherTest {
|
|||
FourCornerZion7Candlelier writerX06 = FourCornerZionStenoGrapher.writerX06(outX06);
|
||||
FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18);
|
||||
BigInteger v1 = BigInteger.valueOf(123);
|
||||
writerX06.strobeNCR1632(BigInteger.ONE, v1);
|
||||
writerX18.strobeNCR1632(BigInteger.ONE, v1);
|
||||
writerX06.strobeNumberNCR1632(BigInteger.ONE, v1);
|
||||
writerX18.strobeNumberNCR1632(BigInteger.ONE, v1);
|
||||
BigInteger v2 = BigInteger.valueOf(12345);
|
||||
writerX06.strobeNCR1632(BigInteger.ONE, v2);
|
||||
writerX18.strobeNCR1632(BigInteger.ONE, v2);
|
||||
writerX06.strobeNumberNCR1632(BigInteger.ONE, v2);
|
||||
writerX18.strobeNumberNCR1632(BigInteger.ONE, v2);
|
||||
BigInteger v3 = BigInteger.valueOf(-5432);
|
||||
writerX06.strobeNCR1632(v3, v3);
|
||||
writerX18.strobeNCR1632(v3, v3);
|
||||
writerX06.strobeNumberNCR1632(v3, v3);
|
||||
writerX18.strobeNumberNCR1632(v3, v3);
|
||||
String resX06 = FourCornerUnicodeDisplay.text().renderFromInt18(outX06);
|
||||
String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18);
|
||||
Assertions.assertEquals(resX18, resX06);
|
||||
|
|
@ -106,7 +128,7 @@ public class StenoGrapherTest {
|
|||
writerX18.strobeDocumentAlpha();
|
||||
for (int x = 1; x <= 1025 /*_999999*/; x++) {
|
||||
BigInteger v = BigInteger.valueOf(x);
|
||||
writerX18.strobeNCR1632(BigInteger.ONE, v);
|
||||
writerX18.strobeNumberNCR1632(BigInteger.ONE, v);
|
||||
writerX18.strobeWord(FCDotF4TTY0001DashNL.NETHER_LINE.cakePointDotIndex());
|
||||
}
|
||||
writerX18.strobeDocumentOmega();
|
||||
|
|
@ -133,8 +155,8 @@ public class StenoGrapherTest {
|
|||
FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18);
|
||||
for (int x = 1; x <= 1025; x++) {
|
||||
BigInteger v = BigInteger.valueOf(x);
|
||||
writerX06.strobeNCR1632(BigInteger.ONE, v);
|
||||
writerX18.strobeNCR1632(BigInteger.ONE, v);
|
||||
writerX06.strobeNumberNCR1632(BigInteger.ONE, v);
|
||||
writerX18.strobeNumberNCR1632(BigInteger.ONE, v);
|
||||
}
|
||||
String resX06 = FourCornerUnicodeDisplay.text().renderFromInt18(outX06);
|
||||
String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18);
|
||||
|
|
@ -154,19 +176,19 @@ public class StenoGrapherTest {
|
|||
FourCornerZion7Candlelier writerX06 = FourCornerZionStenoGrapher.writerX06(outX06);
|
||||
FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18);
|
||||
BigInteger maxValue = new BigInteger("7FFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16);
|
||||
writerX06.strobeNCR1632(maxValue, maxValue);
|
||||
writerX06.strobeNumberNCR1632(maxValue, maxValue);
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
writerX06.strobeNCR1632(maxValue, maxValue.add(BigInteger.ONE));
|
||||
writerX06.strobeNumberNCR1632(maxValue, maxValue.add(BigInteger.ONE));
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
writerX06.strobeNCR1632(maxValue.add(BigInteger.ONE), maxValue);
|
||||
writerX06.strobeNumberNCR1632(maxValue.add(BigInteger.ONE), maxValue);
|
||||
});
|
||||
writerX18.strobeNCR1632(maxValue, maxValue);
|
||||
writerX18.strobeNumberNCR1632(maxValue, maxValue);
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
writerX18.strobeNCR1632(maxValue, maxValue.add(BigInteger.ONE));
|
||||
writerX18.strobeNumberNCR1632(maxValue, maxValue.add(BigInteger.ONE));
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
writerX18.strobeNCR1632(maxValue.add(BigInteger.ONE), maxValue);
|
||||
writerX18.strobeNumberNCR1632(maxValue.add(BigInteger.ONE), maxValue);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class StenoLexerNCRTest {
|
|||
Assertions.assertEquals(0, smokeReader.pipeSmokeClouds);
|
||||
lexer.read(cdc);
|
||||
Assertions.assertEquals(1, smokeReader.pipeSmokeClouds);
|
||||
Assertions.assertEquals("burnNCR1632MissingSparkler", smokeReader.pipeError);
|
||||
Assertions.assertEquals("burnNumberNCR1632MissingSparkler", smokeReader.pipeError);
|
||||
|
||||
cdc.addAll(FCDotDEC2701DashPX0.ESC_STOP.baklavaPointSequence()); // the print above auto value + next test
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 123); // normal NXX_123
|
||||
|
|
@ -69,7 +69,7 @@ public class StenoLexerNCRTest {
|
|||
cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() + 123); // normal NXX_123
|
||||
smokeReader.reset();
|
||||
lexer.read(cdc);
|
||||
String res = "[0:1:burnNCR1632MissingSparkler][0:8:burnNCR1632MissingSparkler]¹³⁷⁴³⁸⁹⁵³⁵⁹⁴/₁₃₄₂₁₇₇₃₉[0:16:burnNCR1632MissingSparkler]";
|
||||
String res = "[0:1:burnNumberNCR1632MissingSparkler][0:8:burnNumberNCR1632MissingSparkler]¹³⁷⁴³⁸⁹⁵³⁵⁹⁴/₁₃₄₂₁₇₇₃₉[0:16:burnNumberNCR1632MissingSparkler]";
|
||||
Assertions.assertEquals(res, FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue