diff --git a/aeneas/test/NumberParserTest.v3 b/aeneas/test/NumberParserTest.v3 index d4f8c4d1c..818dc5126 100644 --- a/aeneas/test/NumberParserTest.v3 +++ b/aeneas/test/NumberParserTest.v3 @@ -1,6 +1,147 @@ -def TEST = UnitTest.new("NumberParser", test); +def T = UnitTests.registerT("num:", _, NumberParserTester.new, _); +def X_ = [ + T("Misc", testMisc), + T("Ints", testInts), + T("HexLongs", testHexLongs), + T("DecLongs", testDecLongs), + T("Unsigned", testUnsigned), + T("Types", testTypes), + T("FloatTypes", testFloatTypes), + T("InvalidFloats", testInvalidFloats), + T("Fractional", testFractional), + T("Exponent", testExponent), + T("FloatVal", testFloatVal), + T("DoubleVal", testDoubleVal), + T("Underscore", testUnderscore), + T("Width", testWidth), + () +]; -def test() { +def UINT_TYPE = Int.getType(false, 32); +def LONG_TYPE = Int.getType(true, 64); + +class NumberParserTester(t: Tester) { + def test_implicit_int(val: int, dec: string, hex: string, bin: string) { + y_int(dec, val); + y_int(hex, val); + y_int(bin, val); + } + def test_explicit_uint(val: int, dec: string, hex: string, bin: string) { + y_uint(dec, val); + y_uint(hex, val); + y_uint(bin, val); + } + def y_int(str: string, val: int) { + var p = NumberParser.new(str); + if (!p.parse()) return t.fail1("\"%s\" did not parse", str); + if (p.vtype != Int.TYPE) return t.fail1("\"%s\" should be of type int", str); + if (p.hasSuffix()) return t.fail1("\"%s\" should not have explicit type", str); + var v = p.val; + if (v == null) return t.fail1("\"%d\" was a null Val", val); + if (!Box.?(v)) return t.fail2("\"%s\" was not an int box, was %q", str, V3.renderResult(v, null, _)); + var r = Int.unbox(v); + if (val != r) return t.fail2("\"%s\" parsed as %d", str, r); + } + def y_uint(str: string, val: int) { + var p = NumberParser.new(str); + if (!p.parse()) return t.fail1("\"%s\" did not parse", str); + if (p.vtype != UINT_TYPE) return t.fail1("\"%s\" should be of type int", str); + if (!p.hasSuffix()) return t.fail1("\"%s\" should have explicit type", str); + var v = p.val; + if (v == null) return t.fail1("\"%d\" was a null Val", val); + if (!Box.?(v)) return t.fail2("\"%s\" was not an int box, was %q", str, V3.renderResult(v, null, _)); + var r = Int.unbox(v); + if (val != r) return t.fail2("\"%s\" parsed as %d", str, r); + } + def test_type(str: string, ty: Type) { + var p = NumberParser.new(str); + if (!p.parse()) return t.fail1("\"%s\" did not parse", str); + if (p.vtype != ty) t.fail2("\"%s\" should be of type %q", str, ty.render); + } + def y_long(str: string, val: (int, int)) { + var lval = long.view(val.0) << 32 | u32.view(val.1); + var p = NumberParser.new(str); + if (!p.parse()) return t.fail1("\"%s\" did not parse", str); + if (p.vtype != LONG_TYPE) return t.fail1("\"%s\" should be of type long", str); + if (p.hasSuffix()) return t.fail1("\"%s\" should not have explicit type", str); + var v = p.val; + if (v == null) return t.fail1("\"%s\" parsed to a null Val", str); + if (!Box.?(v)) return t.fail2("\"%s\" was not an long box, was %q", str, V3.renderResult(v, null, _)); + var r = Box.!(v).val; + if (lval != r) return t.fail2("\"%s\" parsed as %q", str, StringBuilder.putd(_, r)); + } + def y_longl(str: string, val: (int, int)) { + var p = NumberParser.new(str); + var lval = long.view(val.0) << 32 | u32.view(val.1); + if (!p.parse()) return t.fail1("\"%s\" did not parse", str); + if (p.pos != str.length) return t.fail1("\"%s\" did not match parsed length", str); + if (p.vtype != LONG_TYPE) return t.fail1("\"%s\" should be of type long", str); + if (!p.hasSuffix()) return t.fail1("\"%s\" should have explicit type", str); + var v = p.val; + if (v == null) return t.fail1("\"%s\" parsed to a null Val", str); + if (!Box.?(v)) return t.fail2("\"%s\" was not an long box, was %q", str, V3.renderResult(v, null, _)); + var r = Box.!(v).val; + if (lval != r) return t.fail2("\"%s\" parsed as %d", str, r); + } + def assert_invalid(str: string) { + var p = NumberParser.new(str); + if (p.parse()) t.fail1("\"%s\" should not parse", str); + } + def assert_len(str: string, len: int) { + var p = NumberParser.new(str); + if (!p.parse() || p.pos != len) t.fail2("\"%s\" should parse of length %d", str, len); + } + + def assert_f(str: string) { + var p = NumberParser.new(str); + if (!p.parse()) return t.fail1("\"%s\" did not parse", str); + if (!p.is_float) return t.fail1("\"%s\" should have .is_float=true", str); + if (p.vtype != Float.FLOAT32) t.fail1("\"%s\" should be of type float", str); + } + def assert_d(str: string) { + var p = NumberParser.new(str); + if (!p.parse()) return t.fail1("\"%s\" did not parse", str); + if (!p.is_float) return t.fail1("\"%s\" should have .is_float=true", str); + if (p.vtype != Float.FLOAT64) t.fail1("\"%s\" should be of type double", str); + } + def assert_fv(str: string, bits: u32) { + var p = NumberParser.new(str); + if (!p.parse()) return t.fail1("\"%s\" did not parse", str); + if (!p.is_float) return t.fail1("\"%s\" should have .is_float=true", str); + if (p.vtype != Float.FLOAT32) return t.fail1("\"%s\" should be of type float", str); + if (!Float32Val.?(p.val)) return t.fail1("\"%s\" should be Float32Val", str); + var got = Float32Val.!(p.val).bits; + if (bits != got) return t.fail3("\"%s\" should be %x, got %x", str, bits, got); + } + def assert_dv(str: string, bits: u64) { + var p = NumberParser.new(str); + if (!p.parse()) return t.fail1("\"%s\" did not parse", str); + if (!p.is_float) return t.fail1("\"%s\" should have .is_float=true", str); + if (p.vtype != Float.FLOAT64) return t.fail1("\"%s\" should be of type double", str); + if (!Float64Val.?(p.val)) return t.fail1("\"%s\" should be Float64Val", str); + var got = Float64Val.!(p.val).bits; + if (bits != got) { + var buf = StringBuilder.new(); + buf.put1("\"%s\" should be ", str); + buf.putx(long.view(bits)); + buf.puts(", got "); + buf.putx(long.view(got)); + return t.fail(buf.toString()); + } + } + def assert_int_type(str: string, signed: bool, width: byte) { + var p = NumberParser.new(str); + p.accept_width = true; + if (!p.parse()) return t.fail1("\"%s\" did not parse", str); + if (!IntType.?(p.vtype)) return t.fail1("\"%s\" should be integral type", str); + var it = IntType.!(p.vtype); + if (it.signed != signed || it.width != width) return t.fail3("\"%s\" expected type %q, got %q", str, Int.getType(signed, width).render, it.render); + } + +} + +def testMisc(t: NumberParserTester) { + def n = t.assert_invalid; n("-"); var hex_buf = "0xx"; @@ -30,661 +171,615 @@ def test() { hex_buf[2] = ch; n(hex_buf); } - - testInts(); - testHexLongs(); - testDecLongs(); - testUnsigned(); - testTypes(); - testFloatTypes(); - testInvalidFloats(); - testFractional(); - testExponent(); - testFloatVal(); - testDoubleVal(); - testUnderscore(); - testWidth(); -} - -def testInts() { - def test = test_implicit_int; - - test(0, "0", "0x0", "0b0"); - test(0, "0", "0x000", "0b0000"); - test(0, "0", "0X0", "0B0"); - test(0, "0", "0X000", "0B0000"); - test(1, "1", "0x1", "0b1"); - test(-1, "-1", "0xffffffff", "0b11111111111111111111111111111111"); - test(2, "2", "0x2", "0b10"); - test(-2, "-2", "0xfffffffe", "0b11111111111111111111111111111110"); - test(3, "3", "0x3", "0b11"); - test(-3, "-3", "0xfffffffd", "0b11111111111111111111111111111101"); - test(4, "4", "0x4", "0b100"); - test(-4, "-4", "0xfffffffc", "0b11111111111111111111111111111100"); - test(5, "5", "0x5", "0b101"); - test(-5, "-5", "0xfffffffb", "0b11111111111111111111111111111011"); - test(-6, "-6", "0xfffffffa", "0b11111111111111111111111111111010"); - test(6, "6", "0x6", "0b110"); - test(7, "7", "0x7", "0b111"); - test(-7, "-7", "0xfffffff9", "0b11111111111111111111111111111001"); - test(8, "8", "0x8", "0b1000"); - test(-8, "-8", "0xfffffff8", "0b11111111111111111111111111111000"); - test(9, "9", "0x9", "0b1001"); - test(-9, "-9", "0xfffffff7", "0b11111111111111111111111111110111"); - test(10, "10", "0xa", "0b1010"); - test(-10, "-10", "0xfffffff6", "0b11111111111111111111111111110110"); - test(11, "11", "0xb", "0b1011"); - test(-11, "-11", "0xfffffff5", "0b11111111111111111111111111110101"); - test(12, "12", "0xc", "0b1100"); - test(-12, "-12", "0xfffffff4", "0b11111111111111111111111111110100"); - test(13, "13", "0xd", "0b1101"); - test(-13, "-13", "0xfffffff3", "0b11111111111111111111111111110011"); - test(14, "14", "0xe", "0b1110"); - test(-14, "-14", "0xfffffff2", "0b11111111111111111111111111110010"); - test(15, "15", "0xf", "0b1111"); - test(-15, "-15", "0xfffffff1", "0b11111111111111111111111111110001"); - test(16, "16", "0x10", "0b10000"); - test(-16, "-16", "0xfffffff0", "0b11111111111111111111111111110000"); - test(17, "17", "0x11", "0b10001"); - test(-17, "-17", "0xffffffef", "0b11111111111111111111111111101111"); - test(18, "18", "0x12", "0b10010"); - test(-18, "-18", "0xffffffee", "0b11111111111111111111111111101110"); - test(23, "23", "0x17", "0b10111"); - test(-23, "-23", "0xffffffe9", "0b11111111111111111111111111101001"); - test(42, "42", "0x2a", "0b101010"); - test(-42, "-42", "0xffffffd6", "0b11111111111111111111111111010110"); - test(56, "56", "0x38", "0b111000"); - test(-56, "-56", "0xffffffc8", "0b11111111111111111111111111001000"); - test(1000000000, "1000000000", "0x3b9aca00", "0b111011100110101100101000000000"); - test(1000000000, "1000000000", "0x3B9ACA00", "0b111011100110101100101000000000"); - test(2000000000, "2000000000", "0x77359400", "0b1110111001101011001010000000000"); - test(2000000000, "2000000000", "0x77359400", "0b1110111001101011001010000000000"); - test(999999999, "999999999", "0x3b9ac9ff", "0b111011100110101100100111111111"); - test(1000000001, "1000000001", "0x3b9aca01", "0b111011100110101100101000000001"); - test(1999999999, "1999999999", "0x773593ff", "0b1110111001101011001001111111111"); - test(2000000001, "2000000001", "0x77359401", "0b1110111001101011001010000000001"); - test(999999998, "999999998", "0x3b9ac9fe", "0b111011100110101100100111111110"); - test(1000000002, "1000000002", "0x3b9aca02", "0b111011100110101100101000000010"); - test(1999999998, "1999999998", "0x773593fe", "0b1110111001101011001001111111110"); - test(2000000002, "2000000002", "0x77359402", "0b1110111001101011001010000000010"); - test(999999997, "999999997", "0x3b9ac9fd", "0b111011100110101100100111111101"); - test(1000000003, "1000000003", "0x3b9aca03", "0b111011100110101100101000000011"); - test(1999999997, "1999999997", "0x773593fd", "0b1110111001101011001001111111101"); - test(2000000003, "2000000003", "0x77359403", "0b1110111001101011001010000000011"); - test(999999996, "999999996", "0x3b9ac9fc", "0b111011100110101100100111111100"); - test(1000000004, "1000000004", "0x3b9aca04", "0b111011100110101100101000000100"); - test(1999999996, "1999999996", "0x773593fc", "0b1110111001101011001001111111100"); - test(2000000004, "2000000004", "0x77359404", "0b1110111001101011001010000000100"); - test(999999995, "999999995", "0x3b9ac9fb", "0b111011100110101100100111111011"); - test(1000000005, "1000000005", "0x3b9aca05", "0b111011100110101100101000000101"); - test(1999999995, "1999999995", "0x773593fb", "0b1110111001101011001001111111011"); - test(2000000005, "2000000005", "0x77359405", "0b1110111001101011001010000000101"); - test(999999994, "999999994", "0x3b9ac9fa", "0b111011100110101100100111111010"); - test(1000000006, "1000000006", "0x3b9aca06", "0b111011100110101100101000000110"); - test(1999999994, "1999999994", "0x773593fa", "0b1110111001101011001001111111010"); - test(2000000006, "2000000006", "0x77359406", "0b1110111001101011001010000000110"); - test(999999993, "999999993", "0x3b9ac9f9", "0b111011100110101100100111111001"); - test(1000000007, "1000000007", "0x3b9aca07", "0b111011100110101100101000000111"); - test(1999999993, "1999999993", "0x773593f9", "0b1110111001101011001001111111001"); - test(2000000007, "2000000007", "0x77359407", "0b1110111001101011001010000000111"); - test(999999992, "999999992", "0x3b9ac9f8", "0b111011100110101100100111111000"); - test(1000000008, "1000000008", "0x3b9aca08", "0b111011100110101100101000001000"); - test(1999999992, "1999999992", "0x773593f8", "0b1110111001101011001001111111000"); - test(2000000008, "2000000008", "0x77359408", "0b1110111001101011001010000001000"); - test(999999991, "999999991", "0x3b9ac9f7", "0b111011100110101100100111110111"); - test(1000000009, "1000000009", "0x3b9aca09", "0b111011100110101100101000001001"); - test(1999999991, "1999999991", "0x773593f7", "0b1110111001101011001001111110111"); - test(2000000009, "2000000009", "0x77359409", "0b1110111001101011001010000001001"); - test(999999990, "999999990", "0x3b9ac9f6", "0b111011100110101100100111110110"); - test(1000000010, "1000000010", "0x3b9aca0a", "0b111011100110101100101000001010"); - test(1999999990, "1999999990", "0x773593f6", "0b1110111001101011001001111110110"); - test(2000000010, "2000000010", "0x7735940a", "0b1110111001101011001010000001010"); - test(999999989, "999999989", "0x3b9ac9f5", "0b111011100110101100100111110101"); - test(1000000011, "1000000011", "0x3b9aca0b", "0b111011100110101100101000001011"); - test(1999999989, "1999999989", "0x773593f5", "0b1110111001101011001001111110101"); - test(2000000011, "2000000011", "0x7735940b", "0b1110111001101011001010000001011"); - test(999999988, "999999988", "0x3b9ac9f4", "0b111011100110101100100111110100"); - test(1000000012, "1000000012", "0x3b9aca0c", "0b111011100110101100101000001100"); - test(1999999988, "1999999988", "0x773593f4", "0b1110111001101011001001111110100"); - test(2000000012, "2000000012", "0x7735940c", "0b1110111001101011001010000001100"); - test(999999987, "999999987", "0x3b9ac9f3", "0b111011100110101100100111110011"); - test(1000000013, "1000000013", "0x3b9aca0d", "0b111011100110101100101000001101"); - test(1999999987, "1999999987", "0x773593f3", "0b1110111001101011001001111110011"); - test(2000000013, "2000000013", "0x7735940d", "0b1110111001101011001010000001101"); - test(999999986, "999999986", "0x3b9ac9f2", "0b111011100110101100100111110010"); - test(1000000014, "1000000014", "0x3b9aca0e", "0b111011100110101100101000001110"); - test(1999999986, "1999999986", "0x773593f2", "0b1110111001101011001001111110010"); - test(2000000014, "2000000014", "0x7735940e", "0b1110111001101011001010000001110"); - test(999999985, "999999985", "0x3b9ac9f1", "0b111011100110101100100111110001"); - test(1000000015, "1000000015", "0x3b9aca0f", "0b111011100110101100101000001111"); - test(1999999985, "1999999985", "0x773593f1", "0b1110111001101011001001111110001"); - test(2000000015, "2000000015", "0x7735940f", "0b1110111001101011001010000001111"); - test(999999984, "999999984", "0x3b9ac9f0", "0b111011100110101100100111110000"); - test(1000000016, "1000000016", "0x3b9aca10", "0b111011100110101100101000010000"); - test(1999999984, "1999999984", "0x773593f0", "0b1110111001101011001001111110000"); - test(2000000016, "2000000016", "0x77359410", "0b1110111001101011001010000010000"); - test(999999983, "999999983", "0x3b9ac9ef", "0b111011100110101100100111101111"); - test(1000000017, "1000000017", "0x3b9aca11", "0b111011100110101100101000010001"); - test(1999999983, "1999999983", "0x773593ef", "0b1110111001101011001001111101111"); - test(2000000017, "2000000017", "0x77359411", "0b1110111001101011001010000010001"); - test(999999982, "999999982", "0x3b9ac9ee", "0b111011100110101100100111101110"); - test(1000000018, "1000000018", "0x3b9aca12", "0b111011100110101100101000010010"); - test(1999999982, "1999999982", "0x773593ee", "0b1110111001101011001001111101110"); - test(2000000018, "2000000018", "0x77359412", "0b1110111001101011001010000010010"); - test(999999977, "999999977", "0x3b9ac9e9", "0b111011100110101100100111101001"); - test(1000000023, "1000000023", "0x3b9aca17", "0b111011100110101100101000010111"); - test(1999999977, "1999999977", "0x773593e9", "0b1110111001101011001001111101001"); - test(2000000023, "2000000023", "0x77359417", "0b1110111001101011001010000010111"); - test(999999958, "999999958", "0x3b9ac9d6", "0b111011100110101100100111010110"); - test(1000000042, "1000000042", "0x3b9aca2a", "0b111011100110101100101000101010"); - test(1999999958, "1999999958", "0x773593d6", "0b1110111001101011001001111010110"); - test(2000000042, "2000000042", "0x7735942a", "0b1110111001101011001010000101010"); - test(999999944, "999999944", "0x3b9ac9c8", "0b111011100110101100100111001000"); - test(1000000056, "1000000056", "0x3b9aca38", "0b111011100110101100101000111000"); - test(1999999944, "1999999944", "0x773593c8", "0b1110111001101011001001111001000"); - test(2000000056, "2000000056", "0x77359438", "0b1110111001101011001010000111000"); - test(77, "77", "0x4d", "0b1001101"); - test(-77, "-77", "0xffffffb3", "0b11111111111111111111111110110011"); - test(999999923, "999999923", "0x3b9ac9b3", "0b111011100110101100100110110011"); - test(1000000077, "1000000077", "0x3b9aca4d", "0b111011100110101100101001001101"); - test(1999999923, "1999999923", "0x773593b3", "0b1110111001101011001001110110011"); - test(2000000077, "2000000077", "0x7735944d", "0b1110111001101011001010001001101"); - test(101, "101", "0x65", "0b1100101"); - test(-101, "-101", "0xffffff9b", "0b11111111111111111111111110011011"); - test(999999899, "999999899", "0x3b9ac99b", "0b111011100110101100100110011011"); - test(1000000101, "1000000101", "0x3b9aca65", "0b111011100110101100101001100101"); - test(1999999899, "1999999899", "0x7735939b", "0b1110111001101011001001110011011"); - test(2000000101, "2000000101", "0x77359465", "0b1110111001101011001010001100101"); - test(125, "125", "0x7d", "0b1111101"); - test(-125, "-125", "0xffffff83", "0b11111111111111111111111110000011"); - test(999999875, "999999875", "0x3b9ac983", "0b111011100110101100100110000011"); - test(1000000125, "1000000125", "0x3b9aca7d", "0b111011100110101100101001111101"); - test(1999999875, "1999999875", "0x77359383", "0b1110111001101011001001110000011"); - test(2000000125, "2000000125", "0x7735947d", "0b1110111001101011001010001111101"); - test(1001, "1001", "0x3e9", "0b1111101001"); - test(-1001, "-1001", "0xfffffc17", "0b11111111111111111111110000010111"); - test(999998999, "999998999", "0x3b9ac617", "0b111011100110101100011000010111"); - test(1000001001, "1000001001", "0x3b9acde9", "0b111011100110101100110111101001"); - test(1999998999, "1999998999", "0x77359017", "0b1110111001101011001000000010111"); - test(2000001001, "2000001001", "0x773597e9", "0b1110111001101011001011111101001"); - test(1120, "1120", "0x460", "0b10001100000"); - test(-1120, "-1120", "0xfffffba0", "0b11111111111111111111101110100000"); - test(999998880, "999998880", "0x3b9ac5a0", "0b111011100110101100010110100000"); - test(1000001120, "1000001120", "0x3b9ace60", "0b111011100110101100111001100000"); - test(1999998880, "1999998880", "0x77358fa0", "0b1110111001101011000111110100000"); - test(2000001120, "2000001120", "0x77359860", "0b1110111001101011001100001100000"); - test(32767, "32767", "0x7fff", "0b111111111111111"); - test(-32767, "-32767", "0xffff8001", "0b11111111111111111000000000000001"); - test(999967233, "999967233", "0x3b9a4a01", "0b111011100110100100101000000001"); - test(1000032767, "1000032767", "0x3b9b49ff", "0b111011100110110100100111111111"); - test(1999967233, "1999967233", "0x77351401", "0b1110111001101010001010000000001"); - test(2000032767, "2000032767", "0x773613ff", "0b1110111001101100001001111111111"); - test(32768, "32768", "0x8000", "0b1000000000000000"); - test(-32768, "-32768", "0xffff8000", "0b11111111111111111000000000000000"); - test(999967232, "999967232", "0x3b9a4a00", "0b111011100110100100101000000000"); - test(1000032768, "1000032768", "0x3b9b4a00", "0b111011100110110100101000000000"); - test(1999967232, "1999967232", "0x77351400", "0b1110111001101010001010000000000"); - test(2000032768, "2000032768", "0x77361400", "0b1110111001101100001010000000000"); - test(32769, "32769", "0x8001", "0b1000000000000001"); - test(-32769, "-32769", "0xffff7fff", "0b11111111111111110111111111111111"); - test(999967231, "999967231", "0x3b9a49ff", "0b111011100110100100100111111111"); - test(1000032769, "1000032769", "0x3b9b4a01", "0b111011100110110100101000000001"); - test(1999967231, "1999967231", "0x773513ff", "0b1110111001101010001001111111111"); - test(2000032769, "2000032769", "0x77361401", "0b1110111001101100001010000000001"); - test(64000, "64000", "0xfa00", "0b1111101000000000"); - test(-64000, "-64000", "0xffff0600", "0b11111111111111110000011000000000"); - test(999936000, "999936000", "0x3b99d000", "0b111011100110011101000000000000"); - test(1000064000, "1000064000", "0x3b9bc400", "0b111011100110111100010000000000"); - test(1999936000, "1999936000", "0x77349a00", "0b1110111001101001001101000000000"); - test(2000064000, "2000064000", "0x77368e00", "0b1110111001101101000111000000000"); - test(65535, "65535", "0xffff", "0b1111111111111111"); - test(-65535, "-65535", "0xffff0001", "0b11111111111111110000000000000001"); - test(999934465, "999934465", "0x3b99ca01", "0b111011100110011100101000000001"); - test(1000065535, "1000065535", "0x3b9bc9ff", "0b111011100110111100100111111111"); - test(1999934465, "1999934465", "0x77349401", "0b1110111001101001001010000000001"); - test(2000065535, "2000065535", "0x773693ff", "0b1110111001101101001001111111111"); - test(65536, "65536", "0x10000", "0b10000000000000000"); - test(-65536, "-65536", "0xffff0000", "0b11111111111111110000000000000000"); - test(999934464, "999934464", "0x3b99ca00", "0b111011100110011100101000000000"); - test(1000065536, "1000065536", "0x3b9bca00", "0b111011100110111100101000000000"); - test(1999934464, "1999934464", "0x77349400", "0b1110111001101001001010000000000"); - test(2000065536, "2000065536", "0x77369400", "0b1110111001101101001010000000000"); - test(1000982, "1000982", "0xf4616", "0b11110100011000010110"); - test(-1000982, "-1000982", "0xfff0b9ea", "0b11111111111100001011100111101010"); - test(998999018, "998999018", "0x3b8b83ea", "0b111011100010111000001111101010"); - test(1001000982, "1001000982", "0x3baa1016", "0b111011101010100001000000010110"); - test(1998999018, "1998999018", "0x77264dea", "0b1110111001001100100110111101010"); - test(2001000982, "2001000982", "0x7744da16", "0b1110111010001001101101000010110"); - test(2147483647, "2147483647", "0x7fffffff", "0b1111111111111111111111111111111"); - test(2147483646, "2147483646", "0x7ffffffe", "0b1111111111111111111111111111110"); - test(-2147483648, "-2147483648", "0x80000000", "0b10000000000000000000000000000000"); - test(-2147483648, "-2147483648", "0x80000000", "0b10000000000000000000000000000000"); - test(2147483647, "2147483647", "0x7fffffff", "0b1111111111111111111111111111111"); - test(-2147483647, "-2147483647", "0x80000001", "0b10000000000000000000000000000001"); - - test(2147483646, "2147483646", "0x7fFFfffE", "0b1111111111111111111111111111110"); - test(999934465, "999934465", "0X3B99CA01", "0B111011100110011100101000000001"); - test(1000065535, "1000065535", "0X3B9BC9FF", "0B111011100110111100100111111111"); - test(999999997, "999999997", "0X3B9AC9FD", "0B111011100110101100100111111101"); - test(-32768, "-32768", "0xFFFF8000", "0b11111111111111111000000000000000"); - test(-32767, "-32767", "0xFFFF8001", "0b11111111111111111000000000000001"); - test(-65536, "-65536", "0xFFFF0000", "0b11111111111111110000000000000000"); - test(-65535, "-65535", "0xFFFF0001", "0b11111111111111110000000000000001"); - test(32768, "32768", "0x8000", "0b01000000000000000"); - test(32768, "32768", "0x8000", "0b00001000000000000000"); - test(32768, "32768", "0x8000", "0b00000000000000001000000000000000"); - - test(3, "3", "0x3", "0b0011"); - test(3, "3", "0x3", "0b000011"); - test(3, "3", "0x3", "0b0000011"); - test(3, "3", "0x3", "0b0000000011"); -} - -def test_implicit_int(val: int, dec: string, hex: string, bin: string) { - y_int(dec, val); - y_int(hex, val); - y_int(bin, val); } -def test_explicit_uint(val: int, dec: string, hex: string, bin: string) { - y_uint(dec, val); - y_uint(hex, val); - y_uint(bin, val); +def testInts(t: NumberParserTester) { + def T = t.test_implicit_int; + + T(0, "0", "0x0", "0b0"); + T(0, "0", "0x000", "0b0000"); + T(0, "0", "0X0", "0B0"); + T(0, "0", "0X000", "0B0000"); + T(1, "1", "0x1", "0b1"); + T(-1, "-1", "0xffffffff", "0b11111111111111111111111111111111"); + T(2, "2", "0x2", "0b10"); + T(-2, "-2", "0xfffffffe", "0b11111111111111111111111111111110"); + T(3, "3", "0x3", "0b11"); + T(-3, "-3", "0xfffffffd", "0b11111111111111111111111111111101"); + T(4, "4", "0x4", "0b100"); + T(-4, "-4", "0xfffffffc", "0b11111111111111111111111111111100"); + T(5, "5", "0x5", "0b101"); + T(-5, "-5", "0xfffffffb", "0b11111111111111111111111111111011"); + T(-6, "-6", "0xfffffffa", "0b11111111111111111111111111111010"); + T(6, "6", "0x6", "0b110"); + T(7, "7", "0x7", "0b111"); + T(-7, "-7", "0xfffffff9", "0b11111111111111111111111111111001"); + T(8, "8", "0x8", "0b1000"); + T(-8, "-8", "0xfffffff8", "0b11111111111111111111111111111000"); + T(9, "9", "0x9", "0b1001"); + T(-9, "-9", "0xfffffff7", "0b11111111111111111111111111110111"); + T(10, "10", "0xa", "0b1010"); + T(-10, "-10", "0xfffffff6", "0b11111111111111111111111111110110"); + T(11, "11", "0xb", "0b1011"); + T(-11, "-11", "0xfffffff5", "0b11111111111111111111111111110101"); + T(12, "12", "0xc", "0b1100"); + T(-12, "-12", "0xfffffff4", "0b11111111111111111111111111110100"); + T(13, "13", "0xd", "0b1101"); + T(-13, "-13", "0xfffffff3", "0b11111111111111111111111111110011"); + T(14, "14", "0xe", "0b1110"); + T(-14, "-14", "0xfffffff2", "0b11111111111111111111111111110010"); + T(15, "15", "0xf", "0b1111"); + T(-15, "-15", "0xfffffff1", "0b11111111111111111111111111110001"); + T(16, "16", "0x10", "0b10000"); + T(-16, "-16", "0xfffffff0", "0b11111111111111111111111111110000"); + T(17, "17", "0x11", "0b10001"); + T(-17, "-17", "0xffffffef", "0b11111111111111111111111111101111"); + T(18, "18", "0x12", "0b10010"); + T(-18, "-18", "0xffffffee", "0b11111111111111111111111111101110"); + T(23, "23", "0x17", "0b10111"); + T(-23, "-23", "0xffffffe9", "0b11111111111111111111111111101001"); + T(42, "42", "0x2a", "0b101010"); + T(-42, "-42", "0xffffffd6", "0b11111111111111111111111111010110"); + T(56, "56", "0x38", "0b111000"); + T(-56, "-56", "0xffffffc8", "0b11111111111111111111111111001000"); + T(1000000000, "1000000000", "0x3b9aca00", "0b111011100110101100101000000000"); + T(1000000000, "1000000000", "0x3B9ACA00", "0b111011100110101100101000000000"); + T(2000000000, "2000000000", "0x77359400", "0b1110111001101011001010000000000"); + T(2000000000, "2000000000", "0x77359400", "0b1110111001101011001010000000000"); + T(999999999, "999999999", "0x3b9ac9ff", "0b111011100110101100100111111111"); + T(1000000001, "1000000001", "0x3b9aca01", "0b111011100110101100101000000001"); + T(1999999999, "1999999999", "0x773593ff", "0b1110111001101011001001111111111"); + T(2000000001, "2000000001", "0x77359401", "0b1110111001101011001010000000001"); + T(999999998, "999999998", "0x3b9ac9fe", "0b111011100110101100100111111110"); + T(1000000002, "1000000002", "0x3b9aca02", "0b111011100110101100101000000010"); + T(1999999998, "1999999998", "0x773593fe", "0b1110111001101011001001111111110"); + T(2000000002, "2000000002", "0x77359402", "0b1110111001101011001010000000010"); + T(999999997, "999999997", "0x3b9ac9fd", "0b111011100110101100100111111101"); + T(1000000003, "1000000003", "0x3b9aca03", "0b111011100110101100101000000011"); + T(1999999997, "1999999997", "0x773593fd", "0b1110111001101011001001111111101"); + T(2000000003, "2000000003", "0x77359403", "0b1110111001101011001010000000011"); + T(999999996, "999999996", "0x3b9ac9fc", "0b111011100110101100100111111100"); + T(1000000004, "1000000004", "0x3b9aca04", "0b111011100110101100101000000100"); + T(1999999996, "1999999996", "0x773593fc", "0b1110111001101011001001111111100"); + T(2000000004, "2000000004", "0x77359404", "0b1110111001101011001010000000100"); + T(999999995, "999999995", "0x3b9ac9fb", "0b111011100110101100100111111011"); + T(1000000005, "1000000005", "0x3b9aca05", "0b111011100110101100101000000101"); + T(1999999995, "1999999995", "0x773593fb", "0b1110111001101011001001111111011"); + T(2000000005, "2000000005", "0x77359405", "0b1110111001101011001010000000101"); + T(999999994, "999999994", "0x3b9ac9fa", "0b111011100110101100100111111010"); + T(1000000006, "1000000006", "0x3b9aca06", "0b111011100110101100101000000110"); + T(1999999994, "1999999994", "0x773593fa", "0b1110111001101011001001111111010"); + T(2000000006, "2000000006", "0x77359406", "0b1110111001101011001010000000110"); + T(999999993, "999999993", "0x3b9ac9f9", "0b111011100110101100100111111001"); + T(1000000007, "1000000007", "0x3b9aca07", "0b111011100110101100101000000111"); + T(1999999993, "1999999993", "0x773593f9", "0b1110111001101011001001111111001"); + T(2000000007, "2000000007", "0x77359407", "0b1110111001101011001010000000111"); + T(999999992, "999999992", "0x3b9ac9f8", "0b111011100110101100100111111000"); + T(1000000008, "1000000008", "0x3b9aca08", "0b111011100110101100101000001000"); + T(1999999992, "1999999992", "0x773593f8", "0b1110111001101011001001111111000"); + T(2000000008, "2000000008", "0x77359408", "0b1110111001101011001010000001000"); + T(999999991, "999999991", "0x3b9ac9f7", "0b111011100110101100100111110111"); + T(1000000009, "1000000009", "0x3b9aca09", "0b111011100110101100101000001001"); + T(1999999991, "1999999991", "0x773593f7", "0b1110111001101011001001111110111"); + T(2000000009, "2000000009", "0x77359409", "0b1110111001101011001010000001001"); + T(999999990, "999999990", "0x3b9ac9f6", "0b111011100110101100100111110110"); + T(1000000010, "1000000010", "0x3b9aca0a", "0b111011100110101100101000001010"); + T(1999999990, "1999999990", "0x773593f6", "0b1110111001101011001001111110110"); + T(2000000010, "2000000010", "0x7735940a", "0b1110111001101011001010000001010"); + T(999999989, "999999989", "0x3b9ac9f5", "0b111011100110101100100111110101"); + T(1000000011, "1000000011", "0x3b9aca0b", "0b111011100110101100101000001011"); + T(1999999989, "1999999989", "0x773593f5", "0b1110111001101011001001111110101"); + T(2000000011, "2000000011", "0x7735940b", "0b1110111001101011001010000001011"); + T(999999988, "999999988", "0x3b9ac9f4", "0b111011100110101100100111110100"); + T(1000000012, "1000000012", "0x3b9aca0c", "0b111011100110101100101000001100"); + T(1999999988, "1999999988", "0x773593f4", "0b1110111001101011001001111110100"); + T(2000000012, "2000000012", "0x7735940c", "0b1110111001101011001010000001100"); + T(999999987, "999999987", "0x3b9ac9f3", "0b111011100110101100100111110011"); + T(1000000013, "1000000013", "0x3b9aca0d", "0b111011100110101100101000001101"); + T(1999999987, "1999999987", "0x773593f3", "0b1110111001101011001001111110011"); + T(2000000013, "2000000013", "0x7735940d", "0b1110111001101011001010000001101"); + T(999999986, "999999986", "0x3b9ac9f2", "0b111011100110101100100111110010"); + T(1000000014, "1000000014", "0x3b9aca0e", "0b111011100110101100101000001110"); + T(1999999986, "1999999986", "0x773593f2", "0b1110111001101011001001111110010"); + T(2000000014, "2000000014", "0x7735940e", "0b1110111001101011001010000001110"); + T(999999985, "999999985", "0x3b9ac9f1", "0b111011100110101100100111110001"); + T(1000000015, "1000000015", "0x3b9aca0f", "0b111011100110101100101000001111"); + T(1999999985, "1999999985", "0x773593f1", "0b1110111001101011001001111110001"); + T(2000000015, "2000000015", "0x7735940f", "0b1110111001101011001010000001111"); + T(999999984, "999999984", "0x3b9ac9f0", "0b111011100110101100100111110000"); + T(1000000016, "1000000016", "0x3b9aca10", "0b111011100110101100101000010000"); + T(1999999984, "1999999984", "0x773593f0", "0b1110111001101011001001111110000"); + T(2000000016, "2000000016", "0x77359410", "0b1110111001101011001010000010000"); + T(999999983, "999999983", "0x3b9ac9ef", "0b111011100110101100100111101111"); + T(1000000017, "1000000017", "0x3b9aca11", "0b111011100110101100101000010001"); + T(1999999983, "1999999983", "0x773593ef", "0b1110111001101011001001111101111"); + T(2000000017, "2000000017", "0x77359411", "0b1110111001101011001010000010001"); + T(999999982, "999999982", "0x3b9ac9ee", "0b111011100110101100100111101110"); + T(1000000018, "1000000018", "0x3b9aca12", "0b111011100110101100101000010010"); + T(1999999982, "1999999982", "0x773593ee", "0b1110111001101011001001111101110"); + T(2000000018, "2000000018", "0x77359412", "0b1110111001101011001010000010010"); + T(999999977, "999999977", "0x3b9ac9e9", "0b111011100110101100100111101001"); + T(1000000023, "1000000023", "0x3b9aca17", "0b111011100110101100101000010111"); + T(1999999977, "1999999977", "0x773593e9", "0b1110111001101011001001111101001"); + T(2000000023, "2000000023", "0x77359417", "0b1110111001101011001010000010111"); + T(999999958, "999999958", "0x3b9ac9d6", "0b111011100110101100100111010110"); + T(1000000042, "1000000042", "0x3b9aca2a", "0b111011100110101100101000101010"); + T(1999999958, "1999999958", "0x773593d6", "0b1110111001101011001001111010110"); + T(2000000042, "2000000042", "0x7735942a", "0b1110111001101011001010000101010"); + T(999999944, "999999944", "0x3b9ac9c8", "0b111011100110101100100111001000"); + T(1000000056, "1000000056", "0x3b9aca38", "0b111011100110101100101000111000"); + T(1999999944, "1999999944", "0x773593c8", "0b1110111001101011001001111001000"); + T(2000000056, "2000000056", "0x77359438", "0b1110111001101011001010000111000"); + T(77, "77", "0x4d", "0b1001101"); + T(-77, "-77", "0xffffffb3", "0b11111111111111111111111110110011"); + T(999999923, "999999923", "0x3b9ac9b3", "0b111011100110101100100110110011"); + T(1000000077, "1000000077", "0x3b9aca4d", "0b111011100110101100101001001101"); + T(1999999923, "1999999923", "0x773593b3", "0b1110111001101011001001110110011"); + T(2000000077, "2000000077", "0x7735944d", "0b1110111001101011001010001001101"); + T(101, "101", "0x65", "0b1100101"); + T(-101, "-101", "0xffffff9b", "0b11111111111111111111111110011011"); + T(999999899, "999999899", "0x3b9ac99b", "0b111011100110101100100110011011"); + T(1000000101, "1000000101", "0x3b9aca65", "0b111011100110101100101001100101"); + T(1999999899, "1999999899", "0x7735939b", "0b1110111001101011001001110011011"); + T(2000000101, "2000000101", "0x77359465", "0b1110111001101011001010001100101"); + T(125, "125", "0x7d", "0b1111101"); + T(-125, "-125", "0xffffff83", "0b11111111111111111111111110000011"); + T(999999875, "999999875", "0x3b9ac983", "0b111011100110101100100110000011"); + T(1000000125, "1000000125", "0x3b9aca7d", "0b111011100110101100101001111101"); + T(1999999875, "1999999875", "0x77359383", "0b1110111001101011001001110000011"); + T(2000000125, "2000000125", "0x7735947d", "0b1110111001101011001010001111101"); + T(1001, "1001", "0x3e9", "0b1111101001"); + T(-1001, "-1001", "0xfffffc17", "0b11111111111111111111110000010111"); + T(999998999, "999998999", "0x3b9ac617", "0b111011100110101100011000010111"); + T(1000001001, "1000001001", "0x3b9acde9", "0b111011100110101100110111101001"); + T(1999998999, "1999998999", "0x77359017", "0b1110111001101011001000000010111"); + T(2000001001, "2000001001", "0x773597e9", "0b1110111001101011001011111101001"); + T(1120, "1120", "0x460", "0b10001100000"); + T(-1120, "-1120", "0xfffffba0", "0b11111111111111111111101110100000"); + T(999998880, "999998880", "0x3b9ac5a0", "0b111011100110101100010110100000"); + T(1000001120, "1000001120", "0x3b9ace60", "0b111011100110101100111001100000"); + T(1999998880, "1999998880", "0x77358fa0", "0b1110111001101011000111110100000"); + T(2000001120, "2000001120", "0x77359860", "0b1110111001101011001100001100000"); + T(32767, "32767", "0x7fff", "0b111111111111111"); + T(-32767, "-32767", "0xffff8001", "0b11111111111111111000000000000001"); + T(999967233, "999967233", "0x3b9a4a01", "0b111011100110100100101000000001"); + T(1000032767, "1000032767", "0x3b9b49ff", "0b111011100110110100100111111111"); + T(1999967233, "1999967233", "0x77351401", "0b1110111001101010001010000000001"); + T(2000032767, "2000032767", "0x773613ff", "0b1110111001101100001001111111111"); + T(32768, "32768", "0x8000", "0b1000000000000000"); + T(-32768, "-32768", "0xffff8000", "0b11111111111111111000000000000000"); + T(999967232, "999967232", "0x3b9a4a00", "0b111011100110100100101000000000"); + T(1000032768, "1000032768", "0x3b9b4a00", "0b111011100110110100101000000000"); + T(1999967232, "1999967232", "0x77351400", "0b1110111001101010001010000000000"); + T(2000032768, "2000032768", "0x77361400", "0b1110111001101100001010000000000"); + T(32769, "32769", "0x8001", "0b1000000000000001"); + T(-32769, "-32769", "0xffff7fff", "0b11111111111111110111111111111111"); + T(999967231, "999967231", "0x3b9a49ff", "0b111011100110100100100111111111"); + T(1000032769, "1000032769", "0x3b9b4a01", "0b111011100110110100101000000001"); + T(1999967231, "1999967231", "0x773513ff", "0b1110111001101010001001111111111"); + T(2000032769, "2000032769", "0x77361401", "0b1110111001101100001010000000001"); + T(64000, "64000", "0xfa00", "0b1111101000000000"); + T(-64000, "-64000", "0xffff0600", "0b11111111111111110000011000000000"); + T(999936000, "999936000", "0x3b99d000", "0b111011100110011101000000000000"); + T(1000064000, "1000064000", "0x3b9bc400", "0b111011100110111100010000000000"); + T(1999936000, "1999936000", "0x77349a00", "0b1110111001101001001101000000000"); + T(2000064000, "2000064000", "0x77368e00", "0b1110111001101101000111000000000"); + T(65535, "65535", "0xffff", "0b1111111111111111"); + T(-65535, "-65535", "0xffff0001", "0b11111111111111110000000000000001"); + T(999934465, "999934465", "0x3b99ca01", "0b111011100110011100101000000001"); + T(1000065535, "1000065535", "0x3b9bc9ff", "0b111011100110111100100111111111"); + T(1999934465, "1999934465", "0x77349401", "0b1110111001101001001010000000001"); + T(2000065535, "2000065535", "0x773693ff", "0b1110111001101101001001111111111"); + T(65536, "65536", "0x10000", "0b10000000000000000"); + T(-65536, "-65536", "0xffff0000", "0b11111111111111110000000000000000"); + T(999934464, "999934464", "0x3b99ca00", "0b111011100110011100101000000000"); + T(1000065536, "1000065536", "0x3b9bca00", "0b111011100110111100101000000000"); + T(1999934464, "1999934464", "0x77349400", "0b1110111001101001001010000000000"); + T(2000065536, "2000065536", "0x77369400", "0b1110111001101101001010000000000"); + T(1000982, "1000982", "0xf4616", "0b11110100011000010110"); + T(-1000982, "-1000982", "0xfff0b9ea", "0b11111111111100001011100111101010"); + T(998999018, "998999018", "0x3b8b83ea", "0b111011100010111000001111101010"); + T(1001000982, "1001000982", "0x3baa1016", "0b111011101010100001000000010110"); + T(1998999018, "1998999018", "0x77264dea", "0b1110111001001100100110111101010"); + T(2001000982, "2001000982", "0x7744da16", "0b1110111010001001101101000010110"); + T(2147483647, "2147483647", "0x7fffffff", "0b1111111111111111111111111111111"); + T(2147483646, "2147483646", "0x7ffffffe", "0b1111111111111111111111111111110"); + T(-2147483648, "-2147483648", "0x80000000", "0b10000000000000000000000000000000"); + T(-2147483648, "-2147483648", "0x80000000", "0b10000000000000000000000000000000"); + T(2147483647, "2147483647", "0x7fffffff", "0b1111111111111111111111111111111"); + T(-2147483647, "-2147483647", "0x80000001", "0b10000000000000000000000000000001"); + + T(2147483646, "2147483646", "0x7fFFfffE", "0b1111111111111111111111111111110"); + T(999934465, "999934465", "0X3B99CA01", "0B111011100110011100101000000001"); + T(1000065535, "1000065535", "0X3B9BC9FF", "0B111011100110111100100111111111"); + T(999999997, "999999997", "0X3B9AC9FD", "0B111011100110101100100111111101"); + T(-32768, "-32768", "0xFFFF8000", "0b11111111111111111000000000000000"); + T(-32767, "-32767", "0xFFFF8001", "0b11111111111111111000000000000001"); + T(-65536, "-65536", "0xFFFF0000", "0b11111111111111110000000000000000"); + T(-65535, "-65535", "0xFFFF0001", "0b11111111111111110000000000000001"); + T(32768, "32768", "0x8000", "0b01000000000000000"); + T(32768, "32768", "0x8000", "0b00001000000000000000"); + T(32768, "32768", "0x8000", "0b00000000000000001000000000000000"); + + T(3, "3", "0x3", "0b0011"); + T(3, "3", "0x3", "0b000011"); + T(3, "3", "0x3", "0b0000011"); + T(3, "3", "0x3", "0b0000000011"); } -def y_int(str: string, val: int) { - var p = NumberParser.new(str); - if (!p.parse()) return TEST.error1("\"%s\" did not parse", str); - if (p.vtype != Int.TYPE) return TEST.error1("\"%s\" should be of type int", str); - if (p.hasSuffix()) return TEST.error1("\"%s\" should not have explicit type", str); - var v = p.val; - if (v == null) return TEST.error1("\"%d\" was a null Val", val); - if (!Box.?(v)) return TEST.error2("\"%s\" was not an int box, was %q", str, V3.renderResult(v, null, _)); - var r = Int.unbox(v); - if (val != r) return TEST.error2("\"%s\" parsed as %d", str, r); +def testHexLongs(t: NumberParserTester) { + def T = t.y_long; + + T("0x000000000", (0, 0)); + T("0x00000000000000", (0, 0)); + T("0x000000000000000", (0, 0)); + T("0x0000000000000000", (0, 0)); + T("0x0000000000000001", (0, 1)); + T("0x0000000000000002", (0, 2)); + T("0x0000000000000003", (0, 3)); + T("0x0000000000000004", (0, 4)); + T("0x0000000000000005", (0, 5)); + T("0x0000000000000006", (0, 6)); + T("0x0000000000000007", (0, 7)); + T("0x0000000000000008", (0, 8)); + T("0x0000000000000009", (0, 9)); + T("0x000000000000000a", (0, 10)); + T("0x000000000000000b", (0, 11)); + T("0x000000000000000c", (0, 12)); + T("0x0000000000000010", (0x00000000, 0x00000010)); + T("0x0000000000000100", (0x00000000, 0x00000100)); + T("0x0000000000001000", (0x00000000, 0x00001000)); + T("0x0000000000010000", (0x00000000, 0x00010000)); + T("0x0000000000100000", (0x00000000, 0x00100000)); + T("0x0000000001000000", (0x00000000, 0x01000000)); + T("0x0000000010000000", (0x00000000, 0x10000000)); + T("0x0000000100000000", (0x00000001, 0x00000000)); + T("0x0000001000000000", (0x00000010, 0x00000000)); + T("0x0000010000000000", (0x00000100, 0x00000000)); + T("0x0000100000000000", (0x00001000, 0x00000000)); + T("0x0001000000000000", (0x00010000, 0x00000000)); + T("0x0010000000000000", (0x00100000, 0x00000000)); + T("0x0100000000000000", (0x01000000, 0x00000000)); + T("0x1000000000000000", (0x10000000, 0x00000000)); + + T("0x0000000000000012", (0x00000000, 0x00000012)); + T("0x0000000000000123", (0x00000000, 0x00000123)); + T("0x000000000000123a", (0x00000000, 0x0000123a)); + T("0x00000000000123aF", (0x00000000, 0x000123aF)); + T("0x0000000000123aF0", (0x00000000, 0x00123aF0)); + T("0x000000000123aF00", (0x00000000, 0x0123aF00)); + T("0x00000000123aF000", (0x00000000, 0x123aF000)); + T("0x0000000123aF0000", (0x00000001, 0x23aF0000)); + T("0x000000123aF00000", (0x00000012, 0x3aF00000)); + T("0x00000123aF000000", (0x00000123, 0xaF000000)); + T("0x0000123aF0000000", (0x0000123a, 0xF0000000)); + T("0x000123aF00000000", (0x000123aF, 0x00000000)); + T("0x00123aF000000000", (0x00123aF0, 0x00000000)); + T("0x0123aF0000000000", (0x0123aF00, 0x00000000)); + T("0x123aF00000000000", (0x123aF000, 0x00000000)); + + T("0xFFFFFFFFFFFFFFFF", (-1, -1)); + T("0xffffffffffffffff", (-1, -1)); + + T("0x3b9a4a003b9b4a00", (999967232, 1000032768)); + T("0x7735140077361400", (1999967232, 2000032768)); + T("0x00008001ffff7fff", (32769, -32769)); + T("0x0008001ffff7fff", (32769, -32769)); + T("0x008001ffff7fff", (32769, -32769)); + T("0x08001ffff7fff", (32769, -32769)); + T("0x8001ffff7fff", (32769, -32769)); + T("0x3b9a49ff3b9b4a01", (999967231, 1000032769)); + T("0x773513ff77361401", (1999967231, 2000032769)); + T("0x0000fa00ffff0600", (64000, -64000)); + T("0x3b99d0003b9bc400", (999936000, 1000064000)); + T("0x77349a0077368e00", (1999936000, 2000064000)); + T("0x0000ffffffff0001", (65535, -65535)); + T("0x3b99ca013b9bc9ff", (999934465, 1000065535)); + T("0x77349401773693ff", (1999934465, 2000065535)); + T("0x00010000ffff0000", (65536, -65536)); + T("0x0010000ffff0000", (65536, -65536)); + T("0x010000ffff0000", (65536, -65536)); + T("0x10000ffff0000", (65536, -65536)); + T("0x3b99ca003b9bca00", (999934464, 1000065536)); + T("0x7734940077369400", (1999934464, 2000065536)); + T("0x000f4616fff0b9ea", (1000982, -1000982)); + T("0x00f4616fff0b9ea", (1000982, -1000982)); + T("0x0f4616fff0b9ea", (1000982, -1000982)); + T("0xf4616fff0b9ea", (1000982, -1000982)); + T("0x3b8b83ea3baa1016", (998999018, 1001000982)); + T("0x77264dea7744da16", (1998999018, 2001000982)); + T("0x7fffffff7ffffffe", (2147483647, 2147483646)); + T("0x8000000080000000", (-2147483648, -2147483648)); + T("0x7fffffff80000001", (2147483647, -2147483647)); } -def UINT_TYPE = Int.getType(false, 32); -def y_uint(str: string, val: int) { - var p = NumberParser.new(str); - if (!p.parse()) return TEST.error1("\"%s\" did not parse", str); - if (p.vtype != UINT_TYPE) return TEST.error1("\"%s\" should be of type int", str); - if (!p.hasSuffix()) return TEST.error1("\"%s\" should have explicit type", str); - var v = p.val; - if (v == null) return TEST.error1("\"%d\" was a null Val", val); - if (!Box.?(v)) return TEST.error2("\"%s\" was not an int box, was %q", str, V3.renderResult(v, null, _)); - var r = Int.unbox(v); - if (val != r) return TEST.error2("\"%s\" parsed as %d", str, r); -} - -def testHexLongs() { - def test = y_long; - test("0x000000000", (0, 0)); - test("0x00000000000000", (0, 0)); - test("0x000000000000000", (0, 0)); - test("0x0000000000000000", (0, 0)); - test("0x0000000000000001", (0, 1)); - test("0x0000000000000002", (0, 2)); - test("0x0000000000000003", (0, 3)); - test("0x0000000000000004", (0, 4)); - test("0x0000000000000005", (0, 5)); - test("0x0000000000000006", (0, 6)); - test("0x0000000000000007", (0, 7)); - test("0x0000000000000008", (0, 8)); - test("0x0000000000000009", (0, 9)); - test("0x000000000000000a", (0, 10)); - test("0x000000000000000b", (0, 11)); - test("0x000000000000000c", (0, 12)); - test("0x0000000000000010", (0x00000000, 0x00000010)); - test("0x0000000000000100", (0x00000000, 0x00000100)); - test("0x0000000000001000", (0x00000000, 0x00001000)); - test("0x0000000000010000", (0x00000000, 0x00010000)); - test("0x0000000000100000", (0x00000000, 0x00100000)); - test("0x0000000001000000", (0x00000000, 0x01000000)); - test("0x0000000010000000", (0x00000000, 0x10000000)); - test("0x0000000100000000", (0x00000001, 0x00000000)); - test("0x0000001000000000", (0x00000010, 0x00000000)); - test("0x0000010000000000", (0x00000100, 0x00000000)); - test("0x0000100000000000", (0x00001000, 0x00000000)); - test("0x0001000000000000", (0x00010000, 0x00000000)); - test("0x0010000000000000", (0x00100000, 0x00000000)); - test("0x0100000000000000", (0x01000000, 0x00000000)); - test("0x1000000000000000", (0x10000000, 0x00000000)); - - test("0x0000000000000012", (0x00000000, 0x00000012)); - test("0x0000000000000123", (0x00000000, 0x00000123)); - test("0x000000000000123a", (0x00000000, 0x0000123a)); - test("0x00000000000123aF", (0x00000000, 0x000123aF)); - test("0x0000000000123aF0", (0x00000000, 0x00123aF0)); - test("0x000000000123aF00", (0x00000000, 0x0123aF00)); - test("0x00000000123aF000", (0x00000000, 0x123aF000)); - test("0x0000000123aF0000", (0x00000001, 0x23aF0000)); - test("0x000000123aF00000", (0x00000012, 0x3aF00000)); - test("0x00000123aF000000", (0x00000123, 0xaF000000)); - test("0x0000123aF0000000", (0x0000123a, 0xF0000000)); - test("0x000123aF00000000", (0x000123aF, 0x00000000)); - test("0x00123aF000000000", (0x00123aF0, 0x00000000)); - test("0x0123aF0000000000", (0x0123aF00, 0x00000000)); - test("0x123aF00000000000", (0x123aF000, 0x00000000)); - - test("0xFFFFFFFFFFFFFFFF", (-1, -1)); - test("0xffffffffffffffff", (-1, -1)); - - test("0x3b9a4a003b9b4a00", (999967232, 1000032768)); - test("0x7735140077361400", (1999967232, 2000032768)); - test("0x00008001ffff7fff", (32769, -32769)); - test("0x0008001ffff7fff", (32769, -32769)); - test("0x008001ffff7fff", (32769, -32769)); - test("0x08001ffff7fff", (32769, -32769)); - test("0x8001ffff7fff", (32769, -32769)); - test("0x3b9a49ff3b9b4a01", (999967231, 1000032769)); - test("0x773513ff77361401", (1999967231, 2000032769)); - test("0x0000fa00ffff0600", (64000, -64000)); - test("0x3b99d0003b9bc400", (999936000, 1000064000)); - test("0x77349a0077368e00", (1999936000, 2000064000)); - test("0x0000ffffffff0001", (65535, -65535)); - test("0x3b99ca013b9bc9ff", (999934465, 1000065535)); - test("0x77349401773693ff", (1999934465, 2000065535)); - test("0x00010000ffff0000", (65536, -65536)); - test("0x0010000ffff0000", (65536, -65536)); - test("0x010000ffff0000", (65536, -65536)); - test("0x10000ffff0000", (65536, -65536)); - test("0x3b99ca003b9bca00", (999934464, 1000065536)); - test("0x7734940077369400", (1999934464, 2000065536)); - test("0x000f4616fff0b9ea", (1000982, -1000982)); - test("0x00f4616fff0b9ea", (1000982, -1000982)); - test("0x0f4616fff0b9ea", (1000982, -1000982)); - test("0xf4616fff0b9ea", (1000982, -1000982)); - test("0x3b8b83ea3baa1016", (998999018, 1001000982)); - test("0x77264dea7744da16", (1998999018, 2001000982)); - test("0x7fffffff7ffffffe", (2147483647, 2147483646)); - test("0x8000000080000000", (-2147483648, -2147483648)); - test("0x7fffffff80000001", (2147483647, -2147483647)); +def testDecLongs(t: NumberParserTester) { + def T = t.y_long; + + T("6392438068", (0x00000001, 0x7D04DD34)); + T("19177314205", (0x00000004, 0x770E979D)); + T("57531942616", (0x0000000D, 0x652BC6D8)); + T("172595827849", (0x00000028, 0x2F835489)); + T("517787483548", (0x00000078, 0x8E89FD9C)); + T("1553362450645", (0x00000169, 0xAB9DF8D5)); + T("4660087351936", (0x0000043D, 0x02D9EA80)); + T("13980262055809", (0x00000CB7, 0x088DBF81)); + T("41940786167428", (0x00002625, 0x19A93E84)); + T("125822358502285", (0x0000726F, 0x4CFBBB8D)); + T("377467075506856", (0x0001574D, 0xE6F332A8)); + T("1132401226520569", (0x000405E9, 0xB4D997F9)); + T("3397203679561708", (0x000C11BD, 0x1E8CC7EC)); + T("10191611038685125", (0x00243537, 0x5BA657C5)); + T("30574833116055376", (0x006C9FA6, 0x12F30750)); + T("91724499348166129", (0x0145DEF2, 0x38D915F1)); + T("275173498044498388", (0x03D19CD6, 0xAA8B41D4)); + T("825520494133495165", (0x0B74D683, 0xFFA1C57D)); + T("2476561482400485496", (0x225E838B, 0xFEE55078)); + T("7429684447201456489", (0x671B8AA3, 0xFCAFF169)); + T("3842309267894817852", (0x35529FEB, 0xF60FD43C)); + + T("-15690529805", (0xFFFFFFFC, 0x58C583F3)); + T("-47071589414", (0xFFFFFFF5, 0x0A508BDA)); + T("-141214768241", (0xFFFFFFDF, 0x1EF1A38F)); + T("-423644304722", (0xFFFFFF9D, 0x5CD4EAAE)); + T("-1270932914165", (0xFFFFFED8, 0x167EC00B)); + T("-3812798742494", (0xFFFFFC88, 0x437C4022)); + T("-11438396227481", (0xFFFFF598, 0xCA74C067)); + T("-34315188682442", (0xFFFFE0CA, 0x5F5E4136)); + T("-102945566047325", (0xFFFFA25F, 0x1E1AC3A3)); + T("-308836698141974", (0xFFFEE71D, 0x5A504AEA)); + T("-926510094425921", (0xFFFCB558, 0x0EF0E0BF)); + T("-2779530283277762", (0xFFF62008, 0x2CD2A23E)); + T("-8338590849833285", (0xFFE26018, 0x8677E6BB)); + T("-25015772549499854", (0xFFA72049, 0x9367B432)); + T("-75047317648499561", (0xFEF560DC, 0xBA371C97)); + T("-225141952945498682", (0xFCE02296, 0x2EA555C6)); + T("-675425858836496045", (0xF6A067C2, 0x8BF00153)); + T("-2026277576509488134", (0xE3E13747, 0xA3D003FA)); + T("-6078832729528464401", (0xABA3A5D6, 0xEB700BEF)); + + T("9223372036854775807", (0x7FFFFFFF, 0xFFFFFFFF)); + T("-9223372036854775808", (0x80000000, 0)); } -def testDecLongs() { - def test = y_long; - test("6392438068", (0x00000001, 0x7D04DD34)); - test("19177314205", (0x00000004, 0x770E979D)); - test("57531942616", (0x0000000D, 0x652BC6D8)); - test("172595827849", (0x00000028, 0x2F835489)); - test("517787483548", (0x00000078, 0x8E89FD9C)); - test("1553362450645", (0x00000169, 0xAB9DF8D5)); - test("4660087351936", (0x0000043D, 0x02D9EA80)); - test("13980262055809", (0x00000CB7, 0x088DBF81)); - test("41940786167428", (0x00002625, 0x19A93E84)); - test("125822358502285", (0x0000726F, 0x4CFBBB8D)); - test("377467075506856", (0x0001574D, 0xE6F332A8)); - test("1132401226520569", (0x000405E9, 0xB4D997F9)); - test("3397203679561708", (0x000C11BD, 0x1E8CC7EC)); - test("10191611038685125", (0x00243537, 0x5BA657C5)); - test("30574833116055376", (0x006C9FA6, 0x12F30750)); - test("91724499348166129", (0x0145DEF2, 0x38D915F1)); - test("275173498044498388", (0x03D19CD6, 0xAA8B41D4)); - test("825520494133495165", (0x0B74D683, 0xFFA1C57D)); - test("2476561482400485496", (0x225E838B, 0xFEE55078)); - test("7429684447201456489", (0x671B8AA3, 0xFCAFF169)); - test("3842309267894817852", (0x35529FEB, 0xF60FD43C)); - - test("-15690529805", (0xFFFFFFFC, 0x58C583F3)); - test("-47071589414", (0xFFFFFFF5, 0x0A508BDA)); - test("-141214768241", (0xFFFFFFDF, 0x1EF1A38F)); - test("-423644304722", (0xFFFFFF9D, 0x5CD4EAAE)); - test("-1270932914165", (0xFFFFFED8, 0x167EC00B)); - test("-3812798742494", (0xFFFFFC88, 0x437C4022)); - test("-11438396227481", (0xFFFFF598, 0xCA74C067)); - test("-34315188682442", (0xFFFFE0CA, 0x5F5E4136)); - test("-102945566047325", (0xFFFFA25F, 0x1E1AC3A3)); - test("-308836698141974", (0xFFFEE71D, 0x5A504AEA)); - test("-926510094425921", (0xFFFCB558, 0x0EF0E0BF)); - test("-2779530283277762", (0xFFF62008, 0x2CD2A23E)); - test("-8338590849833285", (0xFFE26018, 0x8677E6BB)); - test("-25015772549499854", (0xFFA72049, 0x9367B432)); - test("-75047317648499561", (0xFEF560DC, 0xBA371C97)); - test("-225141952945498682", (0xFCE02296, 0x2EA555C6)); - test("-675425858836496045", (0xF6A067C2, 0x8BF00153)); - test("-2026277576509488134", (0xE3E13747, 0xA3D003FA)); - test("-6078832729528464401", (0xABA3A5D6, 0xEB700BEF)); - - test("9223372036854775807", (0x7FFFFFFF, 0xFFFFFFFF)); - test("-9223372036854775808", (0x80000000, 0)); +def testBinLongs(t: NumberParserTester) { + def T = t.y_long; + + T("0b00000101", (0x00000000, 0x00000005)); + T("0b0000010000", (0x00000000, 0x00000010)); + T("0b00000000000110001", (0x00000000, 0x00000031)); + T("0b0000000000000010010100", (0x00000000, 0x00000094)); + T("0b000000000000000110111101", (0x00000000, 0x000001BD)); + T("0b0000000000000000000010100111000", (0x00000000, 0x00000538)); + T("0b0000000000000000000000000000111110101001", (0x00000000, 0x00000FA9)); + T("0b00000000000000000000000000000010111011111100", (0x00000000, 0x00002EFC)); + T("0b00000000000000000000000000000001000110011110101", (0x00000000, 0x00008CF5)); + T("0b00000000000000000000000000011010011011100000", (0x00000000, 0x0001A6E0)); + T("0b0000000000000000000000000000001001111010010100001", (0x00000000, 0x0004F4A1)); + T("0b000000000000000000000000000000011101101110111100100", (0x00000000, 0x000EDDE4)); + T("0b00000000000000000000000000000001011001001100110101101", (0x00000000, 0x002C99AD)); + T("0b000000000000000000000000000000100001011100110100001000", (0x00000000, 0x0085CD08)); + T("0b00000000000000000000000000001100100010110011100011001", (0x00000000, 0x01916719)); + T("0b00000000000000000000100101101000011010101001100", (0x00000000, 0x04B4354C)); + T("0b000000000000000001110000111001001111111100101", (0x00000000, 0x0E1C9FE5)); + + T("0b0000000000000000000000000000000000000000000000000000000000000101", (0x00000000, 0x00000005)); + T("0b0000000000000000000000000000000000000000000000000000000000010000", (0x00000000, 0x00000010)); + T("0b0000000000000000000000000000000000000000000000000000000000110001", (0x00000000, 0x00000031)); + T("0b0000000000000000000000000000000000000000000000000000000010010100", (0x00000000, 0x00000094)); + T("0b0000000000000000000000000000000000000000000000000000000110111101", (0x00000000, 0x000001BD)); + T("0b0000000000000000000000000000000000000000000000000000010100111000", (0x00000000, 0x00000538)); + T("0b0000000000000000000000000000000000000000000000000000111110101001", (0x00000000, 0x00000FA9)); + T("0b0000000000000000000000000000000000000000000000000010111011111100", (0x00000000, 0x00002EFC)); + T("0b0000000000000000000000000000000000000000000000001000110011110101", (0x00000000, 0x00008CF5)); + T("0b0000000000000000000000000000000000000000000000011010011011100000", (0x00000000, 0x0001A6E0)); + T("0b0000000000000000000000000000000000000000000001001111010010100001", (0x00000000, 0x0004F4A1)); + T("0b0000000000000000000000000000000000000000000011101101110111100100", (0x00000000, 0x000EDDE4)); + T("0b0000000000000000000000000000000000000000001011001001100110101101", (0x00000000, 0x002C99AD)); + T("0b0000000000000000000000000000000000000000100001011100110100001000", (0x00000000, 0x0085CD08)); + T("0b0000000000000000000000000000000000000001100100010110011100011001", (0x00000000, 0x01916719)); + T("0b0000000000000000000000000000000000000100101101000011010101001100", (0x00000000, 0x04B4354C)); + T("0b0000000000000000000000000000000000001110000111001001111111100101", (0x00000000, 0x0E1C9FE5)); + T("0b0000000000000000000000000000000000101010010101011101111110110000", (0x00000000, 0x2A55DFB0)); + T("0b0000000000000000000000000000000001111111000000011001111100010001", (0x00000000, 0x7F019F11)); + T("0b0000000000000000000000000000000101111101000001001101110100110100", (0x00000001, 0x7D04DD34)); + T("0b0000000000000000000000000000010001110111000011101001011110011101", (0x00000004, 0x770E979D)); + T("0b0000000000000000000000000000110101100101001010111100011011011000", (0x0000000D, 0x652BC6D8)); + T("0b0000000000000000000000000010100000101111100000110101010010001001", (0x00000028, 0x2F835489)); + T("0b0000000000000000000000000111100010001110100010011111110110011100", (0x00000078, 0x8E89FD9C)); + T("0b0000000000000000000000010110100110101011100111011111100011010101", (0x00000169, 0xAB9DF8D5)); + T("0b0000000000000000000001000011110100000010110110011110101010000000", (0x0000043D, 0x02D9EA80)); + T("0b0000000000000000000011001011011100001000100011011011111110000001", (0x00000CB7, 0x088DBF81)); + T("0b0000000000000000001001100010010100011001101010010011111010000100", (0x00002625, 0x19A93E84)); + T("0b0000000000000000011100100110111101001100111110111011101110001101", (0x0000726F, 0x4CFBBB8D)); + T("0b0000000000000001010101110100110111100110111100110011001010101000", (0x0001574D, 0xE6F332A8)); + T("0b0000000000000100000001011110100110110100110110011001011111111001", (0x000405E9, 0xB4D997F9)); + T("0b0000000000001100000100011011110100011110100011001100011111101100", (0x000C11BD, 0x1E8CC7EC)); + T("0b0000000000100100001101010011011101011011101001100101011111000101", (0x00243537, 0x5BA657C5)); + T("0b0000000001101100100111111010011000010010111100110000011101010000", (0x006C9FA6, 0x12F30750)); + T("0b0000000101000101110111101111001000111000110110010001010111110001", (0x0145DEF2, 0x38D915F1)); + T("0b0000001111010001100111001101011010101010100010110100000111010100", (0x03D19CD6, 0xAA8B41D4)); + T("0b0000101101110100110101101000001111111111101000011100010101111101", (0x0B74D683, 0xFFA1C57D)); + T("0b0010001001011110100000111000101111111110111001010101000001111000", (0x225E838B, 0xFEE55078)); + T("0b0110011100011011100010101010001111111100101011111111000101101001", (0x671B8AA3, 0xFCAFF169)); + T("0b0011010101010010100111111110101111110110000011111101010000111100", (0x35529FEB, 0xF60FD43C)); + T("0b1111111111111111111111111111111111111111111111111111111111111110", (0xFFFFFFFF, 0xFFFFFFFE)); + T("0b1111111111111111111111111111111111111111111111111111111111111011", (0xFFFFFFFF, 0xFFFFFFFB)); + T("0b1111111111111111111111111111111111111111111111111111111111110010", (0xFFFFFFFF, 0xFFFFFFF2)); + T("0b1111111111111111111111111111111111111111111111111111111111010111", (0xFFFFFFFF, 0xFFFFFFD7)); + T("0b1111111111111111111111111111111111111111111111111111111110000110", (0xFFFFFFFF, 0xFFFFFF86)); + T("0b1111111111111111111111111111111111111111111111111111111010010011", (0xFFFFFFFF, 0xFFFFFE93)); + T("0b1111111111111111111111111111111111111111111111111111101110111010", (0xFFFFFFFF, 0xFFFFFBBA)); + T("0b1111111111111111111111111111111111111111111111111111001100101111", (0xFFFFFFFF, 0xFFFFF32F)); + T("0b1111111111111111111111111111111111111111111111111101100110001110", (0xFFFFFFFF, 0xFFFFD98E)); + T("0b1111111111111111111111111111111111111111111111111000110010101011", (0xFFFFFFFF, 0xFFFF8CAB)); + T("0b1111111111111111111111111111111111111111111111101010011000000010", (0xFFFFFFFF, 0xFFFEA602)); + T("0b1111111111111111111111111111111111111111111110111111001000000111", (0xFFFFFFFF, 0xFFFBF207)); + T("0b1111111111111111111111111111111111111111111100111101011000010110", (0xFFFFFFFF, 0xFFF3D616)); + T("0b1111111111111111111111111111111111111111110110111000001001000011", (0xFFFFFFFF, 0xFFDB8243)); + T("0b1111111111111111111111111111111111111111100100101000011011001010", (0xFFFFFFFF, 0xFF9286CA)); + T("0b1111111111111111111111111111111111111110101101111001010001011111", (0xFFFFFFFF, 0xFEB7945F)); + T("0b1111111111111111111111111111111111111100001001101011110100011110", (0xFFFFFFFF, 0xFC26BD1E)); + T("0b1111111111111111111111111111111111110100011101000011011101011011", (0xFFFFFFFF, 0xF474375B)); + T("0b1111111111111111111111111111111111011101010111001010011000010010", (0xFFFFFFFF, 0xDD5CA612)); + T("0b1111111111111111111111111111111110011000000101011111001000110111", (0xFFFFFFFF, 0x9815F237)); + T("0b1111111111111111111111111111111011001000010000011101011010100110", (0xFFFFFFFE, 0xC841D6A6)); + T("0b1111111111111111111111111111110001011000110001011000001111110011", (0xFFFFFFFC, 0x58C583F3)); + T("0b1111111111111111111111111111010100001010010100001000101111011010", (0xFFFFFFF5, 0x0A508BDA)); + T("0b1111111111111111111111111101111100011110111100011010001110001111", (0xFFFFFFDF, 0x1EF1A38F)); + T("0b1111111111111111111111111001110101011100110101001110101010101110", (0xFFFFFF9D, 0x5CD4EAAE)); + T("0b1111111111111111111111101101100000010110011111101100000000001011", (0xFFFFFED8, 0x167EC00B)); + T("0b1111111111111111111111001000100001000011011111000100000000100010", (0xFFFFFC88, 0x437C4022)); + T("0b1111111111111111111101011001100011001010011101001100000001100111", (0xFFFFF598, 0xCA74C067)); + T("0b1111111111111111111000001100101001011111010111100100000100110110", (0xFFFFE0CA, 0x5F5E4136)); + T("0b1111111111111111101000100101111100011110000110101100001110100011", (0xFFFFA25F, 0x1E1AC3A3)); + T("0b1111111111111110111001110001110101011010010100000100101011101010", (0xFFFEE71D, 0x5A504AEA)); + T("0b1111111111111100101101010101100000001110111100001110000010111111", (0xFFFCB558, 0x0EF0E0BF)); + T("0b1111111111110110001000000000100000101100110100101010001000111110", (0xFFF62008, 0x2CD2A23E)); + T("0b1111111111100010011000000001100010000110011101111110011010111011", (0xFFE26018, 0x8677E6BB)); + T("0b1111111110100111001000000100100110010011011001111011010000110010", (0xFFA72049, 0x9367B432)); + T("0b1111111011110101011000001101110010111010001101110001110010010111", (0xFEF560DC, 0xBA371C97)); + T("0b1111110011100000001000101001011000101110101001010101010111000110", (0xFCE02296, 0x2EA555C6)); + T("0b1111011010100000011001111100001010001011111100000000000101010011", (0xF6A067C2, 0x8BF00153)); + T("0b1110001111100001001101110100011110100011110100000000001111111010", (0xE3E13747, 0xA3D003FA)); + T("0b1010101110100011101001011101011011101011011100000000101111101111", (0xABA3A5D6, 0xEB700BEF)); } -def testBinLongs() { - def test = y_long; - test("0b00000101", (0x00000000, 0x00000005)); - test("0b0000010000", (0x00000000, 0x00000010)); - test("0b00000000000110001", (0x00000000, 0x00000031)); - test("0b0000000000000010010100", (0x00000000, 0x00000094)); - test("0b000000000000000110111101", (0x00000000, 0x000001BD)); - test("0b0000000000000000000010100111000", (0x00000000, 0x00000538)); - test("0b0000000000000000000000000000111110101001", (0x00000000, 0x00000FA9)); - test("0b00000000000000000000000000000010111011111100", (0x00000000, 0x00002EFC)); - test("0b00000000000000000000000000000001000110011110101", (0x00000000, 0x00008CF5)); - test("0b00000000000000000000000000011010011011100000", (0x00000000, 0x0001A6E0)); - test("0b0000000000000000000000000000001001111010010100001", (0x00000000, 0x0004F4A1)); - test("0b000000000000000000000000000000011101101110111100100", (0x00000000, 0x000EDDE4)); - test("0b00000000000000000000000000000001011001001100110101101", (0x00000000, 0x002C99AD)); - test("0b000000000000000000000000000000100001011100110100001000", (0x00000000, 0x0085CD08)); - test("0b00000000000000000000000000001100100010110011100011001", (0x00000000, 0x01916719)); - test("0b00000000000000000000100101101000011010101001100", (0x00000000, 0x04B4354C)); - test("0b000000000000000001110000111001001111111100101", (0x00000000, 0x0E1C9FE5)); - - test("0b0000000000000000000000000000000000000000000000000000000000000101", (0x00000000, 0x00000005)); - test("0b0000000000000000000000000000000000000000000000000000000000010000", (0x00000000, 0x00000010)); - test("0b0000000000000000000000000000000000000000000000000000000000110001", (0x00000000, 0x00000031)); - test("0b0000000000000000000000000000000000000000000000000000000010010100", (0x00000000, 0x00000094)); - test("0b0000000000000000000000000000000000000000000000000000000110111101", (0x00000000, 0x000001BD)); - test("0b0000000000000000000000000000000000000000000000000000010100111000", (0x00000000, 0x00000538)); - test("0b0000000000000000000000000000000000000000000000000000111110101001", (0x00000000, 0x00000FA9)); - test("0b0000000000000000000000000000000000000000000000000010111011111100", (0x00000000, 0x00002EFC)); - test("0b0000000000000000000000000000000000000000000000001000110011110101", (0x00000000, 0x00008CF5)); - test("0b0000000000000000000000000000000000000000000000011010011011100000", (0x00000000, 0x0001A6E0)); - test("0b0000000000000000000000000000000000000000000001001111010010100001", (0x00000000, 0x0004F4A1)); - test("0b0000000000000000000000000000000000000000000011101101110111100100", (0x00000000, 0x000EDDE4)); - test("0b0000000000000000000000000000000000000000001011001001100110101101", (0x00000000, 0x002C99AD)); - test("0b0000000000000000000000000000000000000000100001011100110100001000", (0x00000000, 0x0085CD08)); - test("0b0000000000000000000000000000000000000001100100010110011100011001", (0x00000000, 0x01916719)); - test("0b0000000000000000000000000000000000000100101101000011010101001100", (0x00000000, 0x04B4354C)); - test("0b0000000000000000000000000000000000001110000111001001111111100101", (0x00000000, 0x0E1C9FE5)); - test("0b0000000000000000000000000000000000101010010101011101111110110000", (0x00000000, 0x2A55DFB0)); - test("0b0000000000000000000000000000000001111111000000011001111100010001", (0x00000000, 0x7F019F11)); - test("0b0000000000000000000000000000000101111101000001001101110100110100", (0x00000001, 0x7D04DD34)); - test("0b0000000000000000000000000000010001110111000011101001011110011101", (0x00000004, 0x770E979D)); - test("0b0000000000000000000000000000110101100101001010111100011011011000", (0x0000000D, 0x652BC6D8)); - test("0b0000000000000000000000000010100000101111100000110101010010001001", (0x00000028, 0x2F835489)); - test("0b0000000000000000000000000111100010001110100010011111110110011100", (0x00000078, 0x8E89FD9C)); - test("0b0000000000000000000000010110100110101011100111011111100011010101", (0x00000169, 0xAB9DF8D5)); - test("0b0000000000000000000001000011110100000010110110011110101010000000", (0x0000043D, 0x02D9EA80)); - test("0b0000000000000000000011001011011100001000100011011011111110000001", (0x00000CB7, 0x088DBF81)); - test("0b0000000000000000001001100010010100011001101010010011111010000100", (0x00002625, 0x19A93E84)); - test("0b0000000000000000011100100110111101001100111110111011101110001101", (0x0000726F, 0x4CFBBB8D)); - test("0b0000000000000001010101110100110111100110111100110011001010101000", (0x0001574D, 0xE6F332A8)); - test("0b0000000000000100000001011110100110110100110110011001011111111001", (0x000405E9, 0xB4D997F9)); - test("0b0000000000001100000100011011110100011110100011001100011111101100", (0x000C11BD, 0x1E8CC7EC)); - test("0b0000000000100100001101010011011101011011101001100101011111000101", (0x00243537, 0x5BA657C5)); - test("0b0000000001101100100111111010011000010010111100110000011101010000", (0x006C9FA6, 0x12F30750)); - test("0b0000000101000101110111101111001000111000110110010001010111110001", (0x0145DEF2, 0x38D915F1)); - test("0b0000001111010001100111001101011010101010100010110100000111010100", (0x03D19CD6, 0xAA8B41D4)); - test("0b0000101101110100110101101000001111111111101000011100010101111101", (0x0B74D683, 0xFFA1C57D)); - test("0b0010001001011110100000111000101111111110111001010101000001111000", (0x225E838B, 0xFEE55078)); - test("0b0110011100011011100010101010001111111100101011111111000101101001", (0x671B8AA3, 0xFCAFF169)); - test("0b0011010101010010100111111110101111110110000011111101010000111100", (0x35529FEB, 0xF60FD43C)); - test("0b1111111111111111111111111111111111111111111111111111111111111110", (0xFFFFFFFF, 0xFFFFFFFE)); - test("0b1111111111111111111111111111111111111111111111111111111111111011", (0xFFFFFFFF, 0xFFFFFFFB)); - test("0b1111111111111111111111111111111111111111111111111111111111110010", (0xFFFFFFFF, 0xFFFFFFF2)); - test("0b1111111111111111111111111111111111111111111111111111111111010111", (0xFFFFFFFF, 0xFFFFFFD7)); - test("0b1111111111111111111111111111111111111111111111111111111110000110", (0xFFFFFFFF, 0xFFFFFF86)); - test("0b1111111111111111111111111111111111111111111111111111111010010011", (0xFFFFFFFF, 0xFFFFFE93)); - test("0b1111111111111111111111111111111111111111111111111111101110111010", (0xFFFFFFFF, 0xFFFFFBBA)); - test("0b1111111111111111111111111111111111111111111111111111001100101111", (0xFFFFFFFF, 0xFFFFF32F)); - test("0b1111111111111111111111111111111111111111111111111101100110001110", (0xFFFFFFFF, 0xFFFFD98E)); - test("0b1111111111111111111111111111111111111111111111111000110010101011", (0xFFFFFFFF, 0xFFFF8CAB)); - test("0b1111111111111111111111111111111111111111111111101010011000000010", (0xFFFFFFFF, 0xFFFEA602)); - test("0b1111111111111111111111111111111111111111111110111111001000000111", (0xFFFFFFFF, 0xFFFBF207)); - test("0b1111111111111111111111111111111111111111111100111101011000010110", (0xFFFFFFFF, 0xFFF3D616)); - test("0b1111111111111111111111111111111111111111110110111000001001000011", (0xFFFFFFFF, 0xFFDB8243)); - test("0b1111111111111111111111111111111111111111100100101000011011001010", (0xFFFFFFFF, 0xFF9286CA)); - test("0b1111111111111111111111111111111111111110101101111001010001011111", (0xFFFFFFFF, 0xFEB7945F)); - test("0b1111111111111111111111111111111111111100001001101011110100011110", (0xFFFFFFFF, 0xFC26BD1E)); - test("0b1111111111111111111111111111111111110100011101000011011101011011", (0xFFFFFFFF, 0xF474375B)); - test("0b1111111111111111111111111111111111011101010111001010011000010010", (0xFFFFFFFF, 0xDD5CA612)); - test("0b1111111111111111111111111111111110011000000101011111001000110111", (0xFFFFFFFF, 0x9815F237)); - test("0b1111111111111111111111111111111011001000010000011101011010100110", (0xFFFFFFFE, 0xC841D6A6)); - test("0b1111111111111111111111111111110001011000110001011000001111110011", (0xFFFFFFFC, 0x58C583F3)); - test("0b1111111111111111111111111111010100001010010100001000101111011010", (0xFFFFFFF5, 0x0A508BDA)); - test("0b1111111111111111111111111101111100011110111100011010001110001111", (0xFFFFFFDF, 0x1EF1A38F)); - test("0b1111111111111111111111111001110101011100110101001110101010101110", (0xFFFFFF9D, 0x5CD4EAAE)); - test("0b1111111111111111111111101101100000010110011111101100000000001011", (0xFFFFFED8, 0x167EC00B)); - test("0b1111111111111111111111001000100001000011011111000100000000100010", (0xFFFFFC88, 0x437C4022)); - test("0b1111111111111111111101011001100011001010011101001100000001100111", (0xFFFFF598, 0xCA74C067)); - test("0b1111111111111111111000001100101001011111010111100100000100110110", (0xFFFFE0CA, 0x5F5E4136)); - test("0b1111111111111111101000100101111100011110000110101100001110100011", (0xFFFFA25F, 0x1E1AC3A3)); - test("0b1111111111111110111001110001110101011010010100000100101011101010", (0xFFFEE71D, 0x5A504AEA)); - test("0b1111111111111100101101010101100000001110111100001110000010111111", (0xFFFCB558, 0x0EF0E0BF)); - test("0b1111111111110110001000000000100000101100110100101010001000111110", (0xFFF62008, 0x2CD2A23E)); - test("0b1111111111100010011000000001100010000110011101111110011010111011", (0xFFE26018, 0x8677E6BB)); - test("0b1111111110100111001000000100100110010011011001111011010000110010", (0xFFA72049, 0x9367B432)); - test("0b1111111011110101011000001101110010111010001101110001110010010111", (0xFEF560DC, 0xBA371C97)); - test("0b1111110011100000001000101001011000101110101001010101010111000110", (0xFCE02296, 0x2EA555C6)); - test("0b1111011010100000011001111100001010001011111100000000000101010011", (0xF6A067C2, 0x8BF00153)); - test("0b1110001111100001001101110100011110100011110100000000001111111010", (0xE3E13747, 0xA3D003FA)); - test("0b1010101110100011101001011101011011101011011100000000101111101111", (0xABA3A5D6, 0xEB700BEF)); -} +def testLSuffix(t: NumberParserTester) { + def T = t.y_longl; -def testLSuffix() { - def test = y_longl; - test("0L", (0,0)); + T("0L", (0,0)); } -def testUnsigned() { - def test = test_explicit_uint; - test(0, "0u", "0x0u", "0b0u"); - test(0, "0u", "0x000u", "0b0000u"); - test(0, "0u", "0X0u", "0B0u"); - test(0, "0u", "0X000u", "0B0000u"); - test(1, "1u", "0x1u", "0b1u"); - test(2, "2u", "0x2u", "0b10u"); - test(3, "3u", "0x3u", "0b11u"); - test(4, "4u", "0x4u", "0b100u"); - test(5, "5u", "0x5u", "0b101u"); - test(6, "6u", "0x6u", "0b110u"); - test(7, "7u", "0x7u", "0b111u"); - test(8, "8u", "0x8u", "0b1000u"); - test(9, "9u", "0x9u", "0b1001u"); - test(10, "10u", "0xau", "0b1010u"); - test(11, "11u", "0xbu", "0b1011u"); - test(12, "12U", "0xcu", "0b1100u"); - test(13, "13U", "0xdU", "0b1101u"); - test(14, "14U", "0xeU", "0b1110u"); - test(15, "15U", "0xfU", "0b1111u"); - test(16, "16U", "0x10u", "0b10000U"); - test(17, "17u", "0x11U", "0b10001U"); - test(18, "18u", "0x12u", "0b10010U"); - test(23, "23u", "0x17U", "0b10111U"); - test(42, "42u", "0x2au", "0b101010U"); - test(56, "56u", "0x38u", "0b111000U"); - test(1000000000, "1000000000u", "0x3b9aca00u", "0b111011100110101100101000000000u"); - test(1000000000, "1000000000u", "0x3B9ACA00u", "0b111011100110101100101000000000u"); - test(2000000000, "2000000000u", "0x77359400u", "0b1110111001101011001010000000000u"); - test(2000000000, "2000000000u", "0x77359400u", "0b1110111001101011001010000000000u"); - test(999999999, "999999999u", "0x3b9ac9ffu", "0b111011100110101100100111111111u"); - test(1000000001, "1000000001u", "0x3b9aca01u", "0b111011100110101100101000000001u"); - test(1999999999, "1999999999u", "0x773593ffu", "0b1110111001101011001001111111111u"); - test(2000000001, "2000000001u", "0x77359401u", "0b1110111001101011001010000000001u"); - test(999999998, "999999998u", "0x3b9ac9feu", "0b111011100110101100100111111110u"); - test(999999944, "999999944u", "0x3b9ac9c8u", "0b111011100110101100100111001000u"); - test(1000000056, "1000000056u", "0x3b9aca38u", "0b111011100110101100101000111000u"); - test(1999999944, "1999999944u", "0x773593c8u", "0b1110111001101011001001111001000u"); - test(2000000056, "2000000056u", "0x77359438u", "0b1110111001101011001010000111000u"); - test(77, "77u", "0x4du", "0b1001101u"); - test(999999923, "999999923u", "0x3b9ac9b3u", "0b111011100110101100100110110011u"); - test(1000000077, "1000000077u", "0x3b9aca4du", "0b111011100110101100101001001101u"); - test(1999999923, "1999999923u", "0x773593b3u", "0b1110111001101011001001110110011u"); - test(2000000077, "2000000077u", "0x7735944du", "0b1110111001101011001010001001101u"); - test(101, "101u", "0x65u", "0b1100101u"); - test(999999899, "999999899u", "0x3b9ac99bu", "0b111011100110101100100110011011u"); - test(1000000101, "1000000101u", "0x3b9aca65u", "0b111011100110101100101001100101u"); - test(125, "125u", "0x7du", "0b1111101u"); - test(999999875, "999999875u", "0x3b9ac983u", "0b111011100110101100100110000011u"); - test(2000000125, "2000000125u", "0x7735947du", "0b1110111001101011001010001111101u"); - test(1001, "1001u", "0x3e9u", "0b1111101001u"); - test(999998999, "999998999u", "0x3b9ac617u", "0b111011100110101100011000010111u"); - test(2000001001, "2000001001u", "0x773597e9u", "0b1110111001101011001011111101001u"); - test(1120, "1120u", "0x460u", "0b10001100000u"); - test(999998880, "999998880u", "0x3b9ac5a0u", "0b111011100110101100010110100000u"); - test(1000001120, "1000001120u", "0x3b9ace60u", "0b111011100110101100111001100000u"); - test(1999998880, "1999998880u", "0x77358fa0u", "0b1110111001101011000111110100000u"); - test(2000001120, "2000001120u", "0x77359860u", "0b1110111001101011001100001100000u"); - test(32767, "32767u", "0x7fffu", "0b111111111111111u"); - test(999967233, "999967233u", "0x3b9a4a01u", "0b111011100110100100101000000001u"); - test(1000032767, "1000032767u", "0x3b9b49ffu", "0b111011100110110100100111111111u"); - test(1999967233, "1999967233u", "0x77351401u", "0b1110111001101010001010000000001u"); - test(2000032767, "2000032767u", "0x773613ffu", "0b1110111001101100001001111111111u"); - test(32768, "32768u", "0x8000u", "0b1000000000000000u"); - test(999967232, "999967232u", "0x3b9a4a00u", "0b111011100110100100101000000000u"); - test(1000032768, "1000032768u", "0x3b9b4a00u", "0b111011100110110100101000000000u"); - test(1999967232, "1999967232u", "0x77351400u", "0b1110111001101010001010000000000u"); - test(2000032768, "2000032768u", "0x77361400u", "0b1110111001101100001010000000000u"); - test(32769, "32769u", "0x8001u", "0b1000000000000001u"); - test(999967231, "999967231u", "0x3b9a49ffu", "0b111011100110100100100111111111u"); - test(1000032769, "1000032769u", "0x3b9b4a01u", "0b111011100110110100101000000001u"); - test(1999967231, "1999967231u", "0x773513ffu", "0b1110111001101010001001111111111u"); - test(2000032769, "2000032769u", "0x77361401u", "0b1110111001101100001010000000001u"); - test(64000, "64000u", "0xfa00u", "0b1111101000000000u"); - test(999936000, "999936000u", "0x3b99d000u", "0b111011100110011101000000000000u"); - test(1000064000, "1000064000u", "0x3b9bc400u", "0b111011100110111100010000000000u"); - test(1999936000, "1999936000u", "0x77349a00u", "0b1110111001101001001101000000000u"); - test(2000064000, "2000064000u", "0x77368e00u", "0b1110111001101101000111000000000u"); - test(65535, "65535u", "0xffffu", "0b1111111111111111u"); - test(999934465, "999934465u", "0x3b99ca01u", "0b111011100110011100101000000001u"); - test(1000065535, "1000065535u", "0x3b9bc9ffu", "0b111011100110111100100111111111u"); - test(1999934465, "1999934465u", "0x77349401u", "0b1110111001101001001010000000001u"); - test(2000065535, "2000065535u", "0x773693ffu", "0b1110111001101101001001111111111u"); - test(65536, "65536u", "0x10000u", "0b10000000000000000u"); - test(999934464, "999934464u", "0x3b99ca00u", "0b111011100110011100101000000000u"); - test(1000065536, "1000065536u", "0x3b9bca00u", "0b111011100110111100101000000000u"); - test(1999934464, "1999934464u", "0x77349400u", "0b1110111001101001001010000000000u"); - test(2000065536, "2000065536u", "0x77369400u", "0b1110111001101101001010000000000u"); - test(1000982, "1000982u", "0xf4616u", "0b11110100011000010110u"); - test(998999018, "998999018u", "0x3b8b83eau", "0b111011100010111000001111101010u"); - test(1001000982, "1001000982u", "0x3baa1016u", "0b111011101010100001000000010110u"); - test(1998999018, "1998999018u", "0x77264deau", "0b1110111001001100100110111101010u"); - test(2001000982, "2001000982u", "0x7744da16u", "0b1110111010001001101101000010110u"); - test(2147483647, "2147483647u", "0x7fffffffu", "0b1111111111111111111111111111111u"); - test(2147483646, "2147483646u", "0x7ffffffeu", "0b1111111111111111111111111111110u"); - test(2147483647, "2147483647u", "0x7fffffffu", "0b1111111111111111111111111111111u"); - - test(2147483646, "2147483646u", "0x7fFFfffEu", "0b1111111111111111111111111111110u"); - test(999934465, "999934465u", "0X3B99CA01u", "0B111011100110011100101000000001u"); - test(1000065535, "1000065535u", "0X3B9BC9FFu", "0B111011100110111100100111111111u"); - test(999999997, "999999997u", "0X3B9AC9FDu", "0B111011100110101100100111111101u"); - test(32768, "32768u", "0x8000u", "0b01000000000000000u"); - test(32768, "32768u", "0x8000u", "0b00001000000000000000u"); - test(32768, "32768u", "0x8000u", "0b00000000000000001000000000000000u"); - - test(3, "3u", "0x3u", "0b0011u"); - test(3, "3u", "0x3u", "0b000011u"); - test(3, "3u", "0x3u", "0b0000011u"); - test(3, "3u", "0x3u", "0b0000000011u"); +def testUnsigned(t: NumberParserTester) { + def T = t.test_explicit_uint; + + T(0, "0u", "0x0u", "0b0u"); + T(0, "0u", "0x000u", "0b0000u"); + T(0, "0u", "0X0u", "0B0u"); + T(0, "0u", "0X000u", "0B0000u"); + T(1, "1u", "0x1u", "0b1u"); + T(2, "2u", "0x2u", "0b10u"); + T(3, "3u", "0x3u", "0b11u"); + T(4, "4u", "0x4u", "0b100u"); + T(5, "5u", "0x5u", "0b101u"); + T(6, "6u", "0x6u", "0b110u"); + T(7, "7u", "0x7u", "0b111u"); + T(8, "8u", "0x8u", "0b1000u"); + T(9, "9u", "0x9u", "0b1001u"); + T(10, "10u", "0xau", "0b1010u"); + T(11, "11u", "0xbu", "0b1011u"); + T(12, "12U", "0xcu", "0b1100u"); + T(13, "13U", "0xdU", "0b1101u"); + T(14, "14U", "0xeU", "0b1110u"); + T(15, "15U", "0xfU", "0b1111u"); + T(16, "16U", "0x10u", "0b10000U"); + T(17, "17u", "0x11U", "0b10001U"); + T(18, "18u", "0x12u", "0b10010U"); + T(23, "23u", "0x17U", "0b10111U"); + T(42, "42u", "0x2au", "0b101010U"); + T(56, "56u", "0x38u", "0b111000U"); + T(1000000000, "1000000000u", "0x3b9aca00u", "0b111011100110101100101000000000u"); + T(1000000000, "1000000000u", "0x3B9ACA00u", "0b111011100110101100101000000000u"); + T(2000000000, "2000000000u", "0x77359400u", "0b1110111001101011001010000000000u"); + T(2000000000, "2000000000u", "0x77359400u", "0b1110111001101011001010000000000u"); + T(999999999, "999999999u", "0x3b9ac9ffu", "0b111011100110101100100111111111u"); + T(1000000001, "1000000001u", "0x3b9aca01u", "0b111011100110101100101000000001u"); + T(1999999999, "1999999999u", "0x773593ffu", "0b1110111001101011001001111111111u"); + T(2000000001, "2000000001u", "0x77359401u", "0b1110111001101011001010000000001u"); + T(999999998, "999999998u", "0x3b9ac9feu", "0b111011100110101100100111111110u"); + T(999999944, "999999944u", "0x3b9ac9c8u", "0b111011100110101100100111001000u"); + T(1000000056, "1000000056u", "0x3b9aca38u", "0b111011100110101100101000111000u"); + T(1999999944, "1999999944u", "0x773593c8u", "0b1110111001101011001001111001000u"); + T(2000000056, "2000000056u", "0x77359438u", "0b1110111001101011001010000111000u"); + T(77, "77u", "0x4du", "0b1001101u"); + T(999999923, "999999923u", "0x3b9ac9b3u", "0b111011100110101100100110110011u"); + T(1000000077, "1000000077u", "0x3b9aca4du", "0b111011100110101100101001001101u"); + T(1999999923, "1999999923u", "0x773593b3u", "0b1110111001101011001001110110011u"); + T(2000000077, "2000000077u", "0x7735944du", "0b1110111001101011001010001001101u"); + T(101, "101u", "0x65u", "0b1100101u"); + T(999999899, "999999899u", "0x3b9ac99bu", "0b111011100110101100100110011011u"); + T(1000000101, "1000000101u", "0x3b9aca65u", "0b111011100110101100101001100101u"); + T(125, "125u", "0x7du", "0b1111101u"); + T(999999875, "999999875u", "0x3b9ac983u", "0b111011100110101100100110000011u"); + T(2000000125, "2000000125u", "0x7735947du", "0b1110111001101011001010001111101u"); + T(1001, "1001u", "0x3e9u", "0b1111101001u"); + T(999998999, "999998999u", "0x3b9ac617u", "0b111011100110101100011000010111u"); + T(2000001001, "2000001001u", "0x773597e9u", "0b1110111001101011001011111101001u"); + T(1120, "1120u", "0x460u", "0b10001100000u"); + T(999998880, "999998880u", "0x3b9ac5a0u", "0b111011100110101100010110100000u"); + T(1000001120, "1000001120u", "0x3b9ace60u", "0b111011100110101100111001100000u"); + T(1999998880, "1999998880u", "0x77358fa0u", "0b1110111001101011000111110100000u"); + T(2000001120, "2000001120u", "0x77359860u", "0b1110111001101011001100001100000u"); + T(32767, "32767u", "0x7fffu", "0b111111111111111u"); + T(999967233, "999967233u", "0x3b9a4a01u", "0b111011100110100100101000000001u"); + T(1000032767, "1000032767u", "0x3b9b49ffu", "0b111011100110110100100111111111u"); + T(1999967233, "1999967233u", "0x77351401u", "0b1110111001101010001010000000001u"); + T(2000032767, "2000032767u", "0x773613ffu", "0b1110111001101100001001111111111u"); + T(32768, "32768u", "0x8000u", "0b1000000000000000u"); + T(999967232, "999967232u", "0x3b9a4a00u", "0b111011100110100100101000000000u"); + T(1000032768, "1000032768u", "0x3b9b4a00u", "0b111011100110110100101000000000u"); + T(1999967232, "1999967232u", "0x77351400u", "0b1110111001101010001010000000000u"); + T(2000032768, "2000032768u", "0x77361400u", "0b1110111001101100001010000000000u"); + T(32769, "32769u", "0x8001u", "0b1000000000000001u"); + T(999967231, "999967231u", "0x3b9a49ffu", "0b111011100110100100100111111111u"); + T(1000032769, "1000032769u", "0x3b9b4a01u", "0b111011100110110100101000000001u"); + T(1999967231, "1999967231u", "0x773513ffu", "0b1110111001101010001001111111111u"); + T(2000032769, "2000032769u", "0x77361401u", "0b1110111001101100001010000000001u"); + T(64000, "64000u", "0xfa00u", "0b1111101000000000u"); + T(999936000, "999936000u", "0x3b99d000u", "0b111011100110011101000000000000u"); + T(1000064000, "1000064000u", "0x3b9bc400u", "0b111011100110111100010000000000u"); + T(1999936000, "1999936000u", "0x77349a00u", "0b1110111001101001001101000000000u"); + T(2000064000, "2000064000u", "0x77368e00u", "0b1110111001101101000111000000000u"); + T(65535, "65535u", "0xffffu", "0b1111111111111111u"); + T(999934465, "999934465u", "0x3b99ca01u", "0b111011100110011100101000000001u"); + T(1000065535, "1000065535u", "0x3b9bc9ffu", "0b111011100110111100100111111111u"); + T(1999934465, "1999934465u", "0x77349401u", "0b1110111001101001001010000000001u"); + T(2000065535, "2000065535u", "0x773693ffu", "0b1110111001101101001001111111111u"); + T(65536, "65536u", "0x10000u", "0b10000000000000000u"); + T(999934464, "999934464u", "0x3b99ca00u", "0b111011100110011100101000000000u"); + T(1000065536, "1000065536u", "0x3b9bca00u", "0b111011100110111100101000000000u"); + T(1999934464, "1999934464u", "0x77349400u", "0b1110111001101001001010000000000u"); + T(2000065536, "2000065536u", "0x77369400u", "0b1110111001101101001010000000000u"); + T(1000982, "1000982u", "0xf4616u", "0b11110100011000010110u"); + T(998999018, "998999018u", "0x3b8b83eau", "0b111011100010111000001111101010u"); + T(1001000982, "1001000982u", "0x3baa1016u", "0b111011101010100001000000010110u"); + T(1998999018, "1998999018u", "0x77264deau", "0b1110111001001100100110111101010u"); + T(2001000982, "2001000982u", "0x7744da16u", "0b1110111010001001101101000010110u"); + T(2147483647, "2147483647u", "0x7fffffffu", "0b1111111111111111111111111111111u"); + T(2147483646, "2147483646u", "0x7ffffffeu", "0b1111111111111111111111111111110u"); + T(2147483647, "2147483647u", "0x7fffffffu", "0b1111111111111111111111111111111u"); + + T(2147483646, "2147483646u", "0x7fFFfffEu", "0b1111111111111111111111111111110u"); + T(999934465, "999934465u", "0X3B99CA01u", "0B111011100110011100101000000001u"); + T(1000065535, "1000065535u", "0X3B9BC9FFu", "0B111011100110111100100111111111u"); + T(999999997, "999999997u", "0X3B9AC9FDu", "0B111011100110101100100111111101u"); + T(32768, "32768u", "0x8000u", "0b01000000000000000u"); + T(32768, "32768u", "0x8000u", "0b00001000000000000000u"); + T(32768, "32768u", "0x8000u", "0b00000000000000001000000000000000u"); + + T(3, "3u", "0x3u", "0b0011u"); + T(3, "3u", "0x3u", "0b000011u"); + T(3, "3u", "0x3u", "0b0000011u"); + T(3, "3u", "0x3u", "0b0000000011u"); // TODO: test many unsigned numbers between 2^31 and 2^32 - test(-1, "4294967295u", "0xFFFFFFFFu", "0b11111111111111111111111111111111u"); - test(-1, "4294967295U", "0xFFFFFFFFU", "0b11111111111111111111111111111111U"); - test(-2, "4294967294u", "0xFFFFFFFEu", "0b11111111111111111111111111111110u"); - test(-2, "4294967294U", "0xFFFFFFFEU", "0b11111111111111111111111111111110U"); - - test(-2147483648, "2147483648u", "0x80000000u", "0b10000000000000000000000000000000u"); - test(-2147483648, "2147483648U", "0x80000000U", "0b10000000000000000000000000000000U"); - test(-2147483640, "2147483656u", "0x80000008u", "0b10000000000000000000000000001000u"); - test(-2147483640, "2147483656U", "0x80000008U", "0b10000000000000000000000000001000U"); + T(-1, "4294967295u", "0xFFFFFFFFu", "0b11111111111111111111111111111111u"); + T(-1, "4294967295U", "0xFFFFFFFFU", "0b11111111111111111111111111111111U"); + T(-2, "4294967294u", "0xFFFFFFFEu", "0b11111111111111111111111111111110u"); + T(-2, "4294967294U", "0xFFFFFFFEU", "0b11111111111111111111111111111110U"); + + T(-2147483648, "2147483648u", "0x80000000u", "0b10000000000000000000000000000000u"); + T(-2147483648, "2147483648U", "0x80000000U", "0b10000000000000000000000000000000U"); + T(-2147483640, "2147483656u", "0x80000008u", "0b10000000000000000000000000001000u"); + T(-2147483640, "2147483656U", "0x80000008U", "0b10000000000000000000000000001000U"); } -def testTypes() { - def tint = test_type(_, Int.TYPE); - def tlong = test_type(_, LONG_TYPE); - def tuint = test_type(_, Int.getType(false, 32)); - def tulong = test_type(_, Int.getType(false, 64)); +def testTypes(t: NumberParserTester) { + def tint = t.test_type(_, Int.TYPE); + def tlong = t.test_type(_, LONG_TYPE); + def tuint = t.test_type(_, Int.getType(false, 32)); + def tulong = t.test_type(_, Int.getType(false, 64)); tint("0"); tint("1"); @@ -774,135 +869,80 @@ def testTypes() { tulong("42949672951u"); } -def assert_f(str: string) { - var p = NumberParser.new(str); - if (!p.parse()) return TEST.error1("\"%s\" did not parse", str); - if (!p.is_float) return TEST.error1("\"%s\" should have .is_float=true", str); - if (p.vtype != Float.FLOAT32) TEST.error1("\"%s\" should be of type float", str); -} - -def assert_d(str: string) { - var p = NumberParser.new(str); - if (!p.parse()) return TEST.error1("\"%s\" did not parse", str); - if (!p.is_float) return TEST.error1("\"%s\" should have .is_float=true", str); - if (p.vtype != Float.FLOAT64) TEST.error1("\"%s\" should be of type double", str); -} - -def testFloatTypes() { - assert_f("0f"); - assert_f("0F"); - assert_f("1f"); - assert_f("2f"); - assert_f("3f"); - assert_f("4f"); - assert_f("5f"); - assert_f("6f"); - assert_f("7f"); - assert_f("8f"); - assert_f("9f"); - assert_f("-0f"); - assert_f("-0F"); - assert_f("-1f"); - assert_f("-2f"); - assert_f("-3f"); - assert_f("-4f"); - assert_f("-5f"); - assert_f("-6f"); - assert_f("-7f"); - assert_f("-8f"); - assert_f("-9f"); - - assert_d("0d"); - assert_d("0D"); - assert_d("1d"); - assert_d("2d"); - assert_d("3d"); - assert_d("4d"); - assert_d("5d"); - assert_d("6d"); - assert_d("7d"); - assert_d("8d"); - assert_d("9d"); - assert_d("-0"); - assert_d("-0d"); - assert_d("-0D"); - assert_d("-1d"); - assert_d("-2d"); - assert_d("-3d"); - assert_d("-4d"); - assert_d("-5d"); - assert_d("-6d"); - assert_d("-7d"); - assert_d("-8d"); - assert_d("-9d"); - - assert_f("0.0f"); - assert_f("1.3f"); - assert_f("5.6f"); - assert_f("7.9f"); - assert_f("22.3f"); - assert_f("679.83f"); - - assert_d("0.0d"); - assert_d("1.3d"); - assert_d("5.6d"); - assert_d("7.9d"); - assert_d("22.3d"); - assert_d("679.83d"); - - assert_d("0.0"); - assert_d("1.3"); - assert_d("5.6"); - assert_d("7.9"); - assert_d("22.3"); - assert_d("679.83"); -} -def test_type(str: string, t: Type) { - var p = NumberParser.new(str); - if (!p.parse()) return TEST.error1("\"%s\" did not parse", str); - if (p.vtype != t) TEST.error2("\"%s\" should be of type %q", str, t.render); +def testFloatTypes(t: NumberParserTester) { + def F = t.assert_f, D = t.assert_d; + + F("0f"); + F("0F"); + F("1f"); + F("2f"); + F("3f"); + F("4f"); + F("5f"); + F("6f"); + F("7f"); + F("8f"); + F("9f"); + F("-0f"); + F("-0F"); + F("-1f"); + F("-2f"); + F("-3f"); + F("-4f"); + F("-5f"); + F("-6f"); + F("-7f"); + F("-8f"); + F("-9f"); + + D("0d"); + D("0D"); + D("1d"); + D("2d"); + D("3d"); + D("4d"); + D("5d"); + D("6d"); + D("7d"); + D("8d"); + D("9d"); + D("-0"); + D("-0d"); + D("-0D"); + D("-1d"); + D("-2d"); + D("-3d"); + D("-4d"); + D("-5d"); + D("-6d"); + D("-7d"); + D("-8d"); + D("-9d"); + + F("0.0f"); + F("1.3f"); + F("5.6f"); + F("7.9f"); + F("22.3f"); + F("679.83f"); + + D("0.0d"); + D("1.3d"); + D("5.6d"); + D("7.9d"); + D("22.3d"); + D("679.83d"); + + D("0.0"); + D("1.3"); + D("5.6"); + D("7.9"); + D("22.3"); + D("679.83"); } -def LONG_TYPE = Int.getType(true, 64); -def y_long(str: string, val: (int, int)) { - var lval = long.view(val.0) << 32 | u32.view(val.1); - var p = NumberParser.new(str); - if (!p.parse()) return TEST.error1("\"%s\" did not parse", str); - if (p.vtype != LONG_TYPE) return TEST.error1("\"%s\" should be of type long", str); - if (p.hasSuffix()) return TEST.error1("\"%s\" should not have explicit type", str); - var v = p.val; - if (v == null) return TEST.error1("\"%s\" parsed to a null Val", str); - if (!Box.?(v)) return TEST.error2("\"%s\" was not an long box, was %q", str, V3.renderResult(v, null, _)); - var r = Box.!(v).val; - if (lval != r) return TEST.error2("\"%s\" parsed as %q", str, StringBuilder.putd(_, r)); -} - - -def y_longl(str: string, val: (int, int)) { - var p = NumberParser.new(str); - var lval = long.view(val.0) << 32 | u32.view(val.1); - if (!p.parse()) return TEST.error1("\"%s\" did not parse", str); - if (p.pos != str.length) return TEST.error1("\"%s\" did not match parsed length", str); - if (p.vtype != LONG_TYPE) return TEST.error1("\"%s\" should be of type long", str); - if (!p.hasSuffix()) return TEST.error1("\"%s\" should have explicit type", str); - var v = p.val; - if (v == null) return TEST.error1("\"%s\" parsed to a null Val", str); - if (!Box.?(v)) return TEST.error2("\"%s\" was not an long box, was %q", str, V3.renderResult(v, null, _)); - var r = Box.!(v).val; - if (lval != r) return TEST.error2("\"%s\" parsed as %d", str, r); -} - -def n(str: string) { - var p = NumberParser.new(str); - if (p.parse()) TEST.error1("\"%s\" should not parse", str); -} - -def l(str: string, len: int) { - var p = NumberParser.new(str); - if (!p.parse() || p.pos != len) TEST.error2("\"%s\" should parse of length %d", str, len); -} - -def testInvalidFloats() { +def testInvalidFloats(t: NumberParserTester) { + def n = t.assert_invalid; n("1e"); n("1e+"); n("1e-"); @@ -912,19 +952,23 @@ def testInvalidFloats() { n("--1"); } -def testFractional() { - assert_d("9.0"); - assert_d("8.1"); - assert_d("7.22"); - assert_d("6.333"); - assert_d("5.4444"); - assert_d("4.55555"); - assert_d("3.666666"); - assert_d("2.7777777"); - assert_d("1.88888888"); - assert_d("0.999999999"); - assert_d("-1.88888888"); - assert_d("-0.999999999"); +def testFractional(t: NumberParserTester) { + def n = t.assert_invalid; + def l = t.assert_len; + def F = t.assert_f, D = t.assert_d; + + D("9.0"); + D("8.1"); + D("7.22"); + D("6.333"); + D("5.4444"); + D("4.55555"); + D("3.666666"); + D("2.7777777"); + D("1.88888888"); + D("0.999999999"); + D("-1.88888888"); + D("-0.999999999"); n(".0"); n(".1"); @@ -958,7 +1002,11 @@ def testFractional() { } } -def testExponent() { +def testExponent(t: NumberParserTester) { + def n = t.assert_invalid; + def l = t.assert_len; + def F = t.assert_f, D = t.assert_d; + n("1e"); n("2E"); n("1e*"); @@ -966,42 +1014,42 @@ def testExponent() { n("1e+*"); n("2E-$"); - assert_d("9e0"); - assert_d("8e+0"); - assert_d("7e-0"); - assert_d("6E1"); - assert_d("5E+1"); - assert_d("4E-1"); - assert_d("-9e10"); - assert_d("-8e+20"); - assert_d("-7e-30"); - assert_d("-6E41"); - assert_d("-5E+51"); - assert_d("-4E-61"); - - assert_f("9e5f"); - assert_f("8e+3F"); - assert_f("7e-2f"); - - assert_d("1.0e1"); - assert_d("-3.0e22"); - assert_d("5.0e333"); - assert_d("-7.0e4444"); - assert_d("9.0e55555"); - assert_d("-22.0e666666"); - assert_d("444.0e7777777"); - assert_d("-6666.0e88888888"); - assert_d("88888.0e999999999"); - - assert_d("1.0e-1"); - assert_d("3.0e-22"); - assert_d("5.0e-333"); - assert_d("7.0e-4444"); - assert_d("9.0e-55555"); - assert_d("22.0e-666666"); - assert_d("444.0e-7777777"); - assert_d("6666.0e-88888888"); - assert_d("88888.0e-999999999"); + D("9e0"); + D("8e+0"); + D("7e-0"); + D("6E1"); + D("5E+1"); + D("4E-1"); + D("-9e10"); + D("-8e+20"); + D("-7e-30"); + D("-6E41"); + D("-5E+51"); + D("-4E-61"); + + F("9e5f"); + F("8e+3F"); + F("7e-2f"); + + D("1.0e1"); + D("-3.0e22"); + D("5.0e333"); + D("-7.0e4444"); + D("9.0e55555"); + D("-22.0e666666"); + D("444.0e7777777"); + D("-6666.0e88888888"); + D("88888.0e999999999"); + + D("1.0e-1"); + D("3.0e-22"); + D("5.0e-333"); + D("7.0e-4444"); + D("9.0e-55555"); + D("22.0e-666666"); + D("444.0e-7777777"); + D("6666.0e-88888888"); + D("88888.0e-999999999"); def invalid = "+-=_)(*&^%$#@!`~[{]}\\|;:\'\",<.>/? \t\nabcghijklmnopqrstuvwxyz"; for (t in ["1e0 ", "2E-11 "]) { @@ -1012,840 +1060,810 @@ def testExponent() { } } -def assert_fv(str: string, bits: u32) { - var p = NumberParser.new(str); - if (!p.parse()) return TEST.error1("\"%s\" did not parse", str); - if (!p.is_float) return TEST.error1("\"%s\" should have .is_float=true", str); - if (p.vtype != Float.FLOAT32) return TEST.error1("\"%s\" should be of type float", str); - if (!Float32Val.?(p.val)) return TEST.error1("\"%s\" should be Float32Val", str); - var got = Float32Val.!(p.val).bits; - if (bits != got) return TEST.error3("\"%s\" should be %x, got %x", str, bits, got); -} - -def testFloatVal() { - assert_fv("0f", 0x00000000); - assert_fv("1f", 0x3F800000); - assert_fv("2f", 0x40000000); - assert_fv("3f", 0x40400000); - assert_fv("4f", 0x40800000); - assert_fv("5f", 0x40A00000); - assert_fv("6f", 0x40C00000); - assert_fv("7f", 0x40E00000); - assert_fv("8f", 0x41000000); - assert_fv("9f", 0x41100000); - assert_fv("10f", 0x41200000); - - assert_fv("1e0f", 0x3F800000); - assert_fv("2e0f", 0x40000000); - assert_fv("3e0f", 0x40400000); - assert_fv("4e0f", 0x40800000); - - assert_fv("1e+0f", 0x3F800000); - assert_fv("2e+0f", 0x40000000); - assert_fv("3e+0f", 0x40400000); - assert_fv("4e+0f", 0x40800000); - - assert_fv("1e-0f", 0x3F800000); - assert_fv("2e-0f", 0x40000000); - assert_fv("3e-0f", 0x40400000); - assert_fv("4e-0f", 0x40800000); - - assert_fv("1e1f", 0x41200000); - assert_fv("2e1f", 0x41A00000); - assert_fv("3e1f", 0x41F00000); - assert_fv("4e1f", 0x42200000); - - assert_fv("-1e1f", 0xC1200000); - assert_fv("-2e1f", 0xC1A00000); - assert_fv("-3e1f", 0xC1F00000); - assert_fv("-4e1f", 0xC2200000); - - assert_fv("7e2f", 0x442F0000); - assert_fv("8e3f", 0x45FA0000); - assert_fv("9e4f", 0x47AFC800); - - assert_fv("-5e5f", 0xC8F42400); - assert_fv("-3e6f", 0xCA371B00); - assert_fv("-6e7f", 0xCC64E1C0); - - assert_fv("123F", 0x42F60000); - assert_fv("2345F", 0x45129000); - assert_fv("34567F", 0x47070700); - assert_fv("456789F", 0x48DF0AA0); - - assert_fv("16777214f", 0x4B7FFFFE); - assert_fv("16777215f", 0x4B7FFFFF); - assert_fv("16777216f", 0x4B800000); - - assert_fv("-33554430f", 0xCBFFFFFF); - assert_fv("-33554431f", 0xCC000000); - assert_fv("-33554432f", 0xCC000000); - assert_fv("-33554433f", 0xCC000000); - assert_fv("-33554434f", 0xCC000000); - assert_fv("-33554435f", 0xCC000001); - - assert_fv("-335544331f", 0xCDA00000); - assert_fv("-335544342f", 0xCDA00001); - assert_fv("-335544353f", 0xCDA00001); - - assert_fv("-3355443316f", 0xCF480000); - assert_fv("-3355443427f", 0xCF480001); - assert_fv("-3355443538f", 0xCF480001); - - assert_fv("-3.355443316e9f", 0xCF480000); - assert_fv("-3.355443427e9f", 0xCF480001); - assert_fv("-3.355443538e9f", 0xCF480001); - - assert_fv("33554433160f", 0x50FA0001); - assert_fv("33554434272f", 0x50FA0001); - assert_fv("33554435384f", 0x50FA0002); - assert_fv("33e12f", 0x55F01B4A); - assert_fv("44e13f", 0x57C816BE); - assert_fv("55e14f", 0x599C51C4); - assert_fv("66e15f", 0x5B6A7AA6); - assert_fv("77e16f", 0x5D2AF96F); - assert_fv("88e17f", 0x5EF43FC3); - assert_fv("99e18f", 0x60ABBCD5); - - assert_fv("3.3554433160e10f", 0x50FA0001); - assert_fv("33.554433160e9f", 0x50FA0001); - assert_fv("335.54433160e8f", 0x50FA0001); - assert_fv("3355.4433160e7f", 0x50FA0001); - assert_fv("33554.433160e6f", 0x50FA0001); - assert_fv("335544.33160e5f", 0x50FA0001); - assert_fv("3355443.3160e4f", 0x50FA0001); - assert_fv("33554433.160e3f", 0x50FA0001); - assert_fv("335544331.60e2f", 0x50FA0001); - assert_fv("3355443316.0e1f", 0x50FA0001); - - assert_fv("3.3e13f", 0x55F01B4A); - assert_fv("4.4e14f", 0x57C816BE); - assert_fv("5.5e15f", 0x599C51C4); - assert_fv("6.6e16f", 0x5B6A7AA6); - assert_fv("7.7e17f", 0x5D2AF96F); - assert_fv("8.8e18f", 0x5EF43FC3); - assert_fv("9.9e19f", 0x60ABBCD5); - - assert_fv("3000000000000000000000000000000f", 0x72177617); - assert_fv("3e30f", 0x72177617); - - assert_fv("7e20f", 0x6217C9CE); - assert_fv("7e21f", 0x63BDBC42); - assert_fv("7e22f", 0x656D2B52); - assert_fv("7e23f", 0x67143B13); - assert_fv("7e24f", 0x68B949D8); - assert_fv("7e25f", 0x6A679C4E); - assert_fv("7e26f", 0x6C10C1B1); - assert_fv("7e27f", 0x6DB4F21D); - assert_fv("7e28f", 0x6F622EA5); - assert_fv("7e29f", 0x710D5D27); - assert_fv("7e30f", 0x72B0B471); - assert_fv("7e31f", 0x745CE18D); - assert_fv("7e32f", 0x760A0CF8); - assert_fv("7e33f", 0x77AC9036); - assert_fv("7e34f", 0x7957B443); - assert_fv("7e35f", 0x7B06D0AA); - assert_fv("7e36f", 0x7CA884D5); - assert_fv("7e37f", 0x7E52A60A); - assert_fv("7e38f", 0x7F800000); - assert_fv("7e39f", 0x7F800000); - assert_fv("7e40f", 0x7F800000); - assert_fv("7e41f", 0x7F800000); - assert_fv("7e42f", 0x7F800000); - - assert_fv("7.0e20f", 0x6217C9CE); - assert_fv("7.00e21f", 0x63BDBC42); - assert_fv("7.000e22f", 0x656D2B52); - assert_fv("7.0000e23f", 0x67143B13); - - assert_fv("71234567890f", 0x5184AF4A); - assert_fv("712345678901234567890f", 0x621A7721); - assert_fv("7123456789012345678901234567890f", 0x72B3D243); - assert_fv("71234567890123456789012345678901234567890f", 0x7F800000); - - assert_fv("0.1e1f", 0x3F800000); - assert_fv("0.01e2f", 0x3F800000); - assert_fv("0.001e3f", 0x3F800000); - assert_fv("0.0001e4f", 0x3F800000); - assert_fv("0.00001e5f", 0x3F800000); - assert_fv("0.000001e6f", 0x3F800000); - - assert_fv("0e-0f", 0x00000000); - assert_fv("0e-2f", 0x00000000); - assert_fv("0e-32f", 0x00000000); - assert_fv("-0e-0f", 0x80000000); - assert_fv("-0e-32f", 0x80000000); - - assert_fv("0.0e-0f", 0x00000000); - assert_fv("0.00e-2f", 0x00000000); - assert_fv("0.000e-32f", 0x00000000); - assert_fv("-0.0000e-0f", 0x80000000); - assert_fv("-0.00000e-32f", 0x80000000); - - assert_fv("0.25f", 0x3e800000); - assert_fv("0.1f", 0x3dcccccd); - assert_fv("0.2f", 0x3e4ccccd); - assert_fv("0.3f", 0x3e99999a); - assert_fv("0.4f", 0x3ecccccd); - assert_fv("0.5f", 0x3f000000); - assert_fv("0.6f", 0x3f19999a); - assert_fv("0.7f", 0x3f333333); - assert_fv("0.8f", 0x3f4ccccd); - assert_fv("0.9f", 0x3f666666); - assert_fv("1.2f", 0x3f99999a); - assert_fv("1.3f", 0x3fa66666); - assert_fv("1.4f", 0x3fb33333); - assert_fv("1.5f", 0x3fc00000); - assert_fv("1.6f", 0x3fcccccd); - assert_fv("1.7f", 0x3fd9999a); - assert_fv("1.8f", 0x3fe66666); - assert_fv("1.9f", 0x3ff33333); - assert_fv("0.77f", 0x3f451eb8); - assert_fv("-0.888f", 0xbf6353f8); - assert_fv("0.055f", 0x3d6147ae); - assert_fv("-0.003f", 0xbb449ba6); - assert_fv("0.000256f", 0x398637bd); - - assert_fv("0.00000000000000000000000000000000000000001e35f", 0x358637bd); - assert_fv("0.00000000000000000000000000000000000000001e36f", 0x3727c5ac); - assert_fv("0.00000000000000000000000000000000000000001e37f", 0x38d1b717); - assert_fv("0.00000000000000000000000000000000000000001e38f", 0x3a83126f); - assert_fv("0.00000000000000000000000000000000000000001e39f", 0x3c23d70a); - assert_fv("0.00000000000000000000000000000000000000001e40f", 0x3dcccccd); - assert_fv("0.00000000000000000000000000000000000000001e41f", 0x3f800000); - assert_fv("0.00000000000000000000000000000000000000001e42f", 0x41200000); - assert_fv("0.00000000000000000000000000000000000000001e43f", 0x42c80000); - - assert_fv("185.72412200915e1f", 0x44e827b8); - assert_fv("4.7302596179249e2f", 0x43ec8353); - assert_fv("5615494048341.8e5f", 0x5cf960c7); - assert_fv("7342260514584.7e7f", 0x607ebc60); - assert_fv("7.9884410687136e8f", 0x4e3e7593); - assert_fv("294685302509.94e9f", 0x617f9948); - assert_fv("7620831416.3202e10f", 0x6084334a); - assert_fv("-35516375.575608e2f", 0xcf53b1b0); - assert_fv("-92.774285393734e3f", 0xc7b53325); - assert_fv("-137.59529062660e4f", 0xc9a7f687); - assert_fv("-43477.918874861e6f", 0xd121f7c6); - assert_fv("-29206538413.631e7f", 0xdc81b3fd); - assert_fv("-79487457.048481e8f", 0xd9e1eabd); - assert_fv("-2129829.7340178e9f", 0xd8f22234); - assert_fv("-131565661.09411e10f", 0xdd921136); - assert_fv("27.188681084028e1f", 0x4387f183); - assert_fv("22.719239557501e2f", 0x450dfec9); - assert_fv("43761692.688262e3f", 0x51230667); - assert_fv("921426.31951767e4f", 0x50094da0); - assert_fv("17386950816.168e5f", 0x58c5aab0); - assert_fv("82181777.925024e6f", 0x56957cdf); - assert_fv("72.930837573463e8f", 0x4fd959d0); - assert_fv("180654568.93720e9f", 0x5c207418); - assert_fv("807024110.94844e10f", 0x5edffe83); - assert_fv("-209792113238.85e1f", 0xd3f43aec); - assert_fv("-4588377705.8484e2f", 0xd2d5a9ba); - assert_fv("-81510.845965265e3f", 0xcc9b7838); - assert_fv("-33143209.696364e4f", 0xd29a55c9); - assert_fv("-479110.62517607e5f", 0xd1327b8d); - assert_fv("-773507.38820913e7f", 0xd4e11ecb); - assert_fv("-168397810346.80e8f", 0xdf69b2ec); - assert_fv("-13.005293084012e9f", 0xd041cb42); - assert_fv("-8537194723170.0e10f", 0xe590a02e); - assert_fv("6254865735.8453e1f", 0x5169030c); - assert_fv("1731230.5098861e2f", 0x4d251a5f); - assert_fv("57173556.438299e3f", 0x5154fcf4); - assert_fv("2774761115603.8e5f", 0x5c7672c3); - assert_fv("8.6915836797536e6f", 0x4b049f80); - assert_fv("180.91048751753e7f", 0x4ed7a980); - assert_fv("8.5644244527073e8f", 0x4e4c3119); - assert_fv("2.6993198547353e9f", 0x4f20e45a); - - assert_fv("9516.6979653034286801107378e21f", 0x68fbe7a7); - assert_fv("5458099002.0985476800540042e22f", 0x742c3a2c); - assert_fv("167336613270.16623700965846e24f", 0x7a00e954); - assert_fv("-2136634670700.0542637549382e22f", 0xf883ae27); - assert_fv("-554143678.86087209690274809e23f", 0xf42edb5f); - assert_fv("1033335001801.3347779336833e20f", 0x74a30811); - assert_fv("61.216566195503108036373989e22f", 0x6701a191); - assert_fv("-99831.029760844545783406252e20f", 0xe9042012); - assert_fv("-681.63190203986626280183378e21f", 0xe7105757); - assert_fv("433562013897498235.44047013e20f", 0x7e027867); - assert_fv("623.74999688324855696644183e22f", 0x68a51af2); - assert_fv("31.888863826233584205293094e23f", 0x6828d178); - assert_fv("631449247027208571870.94688e20f", 0x7f800000); - assert_fv("-2336793464514665.3189416421e25f", 0xff800000); - - assert_fv("6500.8975612e-20f", 0x2495e687); - assert_fv("7279324.9022e-21f", 0x280321f6); - assert_fv("7249213.5844e-22f", 0x2650f1c1); - assert_fv("22.118349986e-23f", 0x1b85b27d); - assert_fv("1680.4913394e-24f", 0x1cfdf2dc); - assert_fv("7028517.9322e-25f", 0x214f71fb); - assert_fv("-2815.9283089e-20f", 0xa401dc9d); - assert_fv("-915167294.09e-21f", 0xab80cc60); - assert_fv("-38.790096392e-22f", 0x9d928b7b); - assert_fv("-7219413819.7e-23f", 0xa9a29116); - assert_fv("-2789.8602027e-24f", 0x9d52cbbf); - assert_fv("-9209.7866623e-25f", 0x9c8b2ca3); - assert_fv("63695579.824e-20f", 0x2b334981); - assert_fv("886683.19190e-21f", 0x267f91ac); - assert_fv("5075558065.7e-22f", 0x2b0edd40); - assert_fv("70620106.039e-23f", 0x264b8c71); - assert_fv("2098.0362120e-24f", 0x1d1e85ec); - assert_fv("8222952790.8e-25f", 0x266d02af); - assert_fv("-35.110694492e-20f", 0xa0cf41c8); - assert_fv("-4702.9959135e-21f", 0xa2ad828a); - assert_fv("-4.1206162546e-22f", 0x9bf91373); - assert_fv("-831237336.02e-23f", 0xa815be0e); - assert_fv("-88522172.984e-24f", 0xa4cc1e45); - assert_fv("-260.47278336e-25f", 0x99fbe9f0); - assert_fv("25166.643208e-20f", 0x25911369); - assert_fv("403855.64762e-21f", 0x25e8ce93); - assert_fv("822158130.23e-22f", 0x29b92230); - assert_fv("895.94617781e-23f", 0x1e293d4c); - assert_fv("2.4165007388e-24f", 0x183af7ba); - assert_fv("4980.6450018e-25f", 0x1c1687e0); - - assert_fv("9898221099373760452432004214463178514232396176102051629.3262574807486478523095921804235158439917196128e-50f", 0x47c1531b); - assert_fv("628195315932329837240373787952.72272571256058789639887141320206244957439104308759971954412551804132921e-51f", 0x1c3ddc42); - assert_fv("71266646067357792083159028241532231341651553017449710170753835622762883652074590114.460446334264986207e-52f", 0x72b3e6fe); - assert_fv("28860920170358551844751866177713959174937116163976699335122616309803326883480.527051473550462029339773e-53f", 0x66747625); - assert_fv("9622770093766661066278657025766503317565584236268310447676869076424839331989741.5796060568871094140562e-55f", 0x674bc524); - assert_fv("265059469745793762195083470727223228095957648623578506113392626417719626085374.46907942618002358159462e-56f", 0x630fb064); - assert_fv("49151520377435578293480798031909732997983740857622296326806327690.305186320393056401832977546941044141e-57f", 0x4c3b7f88); - assert_fv("322911015799560802930301140645012892848917166.88248536301678575194449943615925118039659556582806602248e-58f", 0x29116d1b); - assert_fv("13873755635452835866707032152757462841822.712751691774788369373846175929823920996008508002750362746373e-59f", 0x2023cada); - assert_fv("8018751607103526301813006647748254211.1140044261280317353790270432336986888744019868305924628456188248e-60f", 0x191b1aef); - assert_fv("7487504180538780603062658120149412332957864670.2950943988098802107524184756806578174747717265670839746e-61f", 0x2657d008); - assert_fv("331576089996596550440770874834375147287044.33180482729350555696144717534561721903859117273298097188819e-63f", 0x1bc86cea); - assert_fv("44750714092811261827250288422280157129504950464891031138004994464977889298375.802767929724780226789236e-64f", 0x54823de1); - assert_fv("2858360453254539933790224661576666503622724366236774850710336836832182398286958789409296395458.1261086e-65f", 0x6eb8b79b); - assert_fv("-822092086175131254660938944127449900101107982289741796799361503261934.18912996456493577368044640124852e-50f", 0xdee42d28); - assert_fv("-556952.16536595859396418343473873745152120725837356500162613770304555849322221028446221530060574131323e-51f", 0x80000000); - assert_fv("-432254910899854160088452528846111672261083266509683694352541924739507680094422.77595046830292927956714e-52f", 0xea0f056a); - assert_fv("-6762115379473203174343553921760256089733466396823666464993838920100024.9529392317932325795475969719535e-53f", 0xdb703d15); - assert_fv("-77.832217639202604332883124500037408421959246205016607253096265760102129864551793910444026581472227980e-55f", 0x80000000); - assert_fv("-2526263342524521713528678061066.5502393118249575094303713039074280708583352786881678039676444187783916e-56f", 0x94fa3063); - assert_fv("-540042.03832322042193603594331928821695308216140823166666083764351616614258916825152779791177618028106e-57f", 0x80000000); - assert_fv("-32844504597231239494006292226103444278552871786177891546092488288111683180.400796934054330320697151892e-58f", 0xd93ab30b); - assert_fv("-31743202577835485285450956.365482906258478283984248675182829399837770759292732785008301497049865976606e-59f", 0x87d2f843); - assert_fv("-556.27647871502760621103455978886480727434642043275681576287584797088520757896508433660154982640272659e-60f", 0x80000000); - assert_fv("-299607339670536189315991837914784538609222877289559629399303164579544062025.55608521409424987618735777e-61f", 0xd5d9fe37); - assert_fv("-872801179392882698780532203412475719175553611302194508037283048431667082237.20360656175107630127091915e-62f", 0xd4fe04c1); - assert_fv("-4.8048389681418483617357741795408082397543418570485194588201355408796368536165517170081678709148840331e-63f", 0x80000000); - assert_fv("-556100963915704027.49432288135667720637157077217593156414811833687548305451472542756471127476670224321e-64f", 0x80000000); - assert_fv("-73660138684932314536696203847517810.373998118985404150059245249755490698291199708251048494127776078956e-65f", 0x8d6f0a73); - assert_fv("568056432918239059248149085.96819756672510287709803861737344173298231655640846996435640729201170299587e-51f", 0x172fce11); - assert_fv("36140659944573457531762624505812900541925859495001914598972214192082681577668995551524331.991583569595e-53f", 0x7a8b3571); - assert_fv("949747474795293409361155500215507691636378196352081379090897304735767877037236955167683750.76436118970e-54f", 0x7b36ea2a); - assert_fv("1324270968072772854107680607.6928979760738098592175225757103046994542065558106581040519263108037655351e-55f", 0x1127df0d); - assert_fv("82754011555866363745359908347841407395996.380559697904199831038580137213390177416920406205516485486713e-56f", 0x266e85af); - assert_fv("990758633065384206565348341606181296081640516129314468002885226245431880.31507668544714275742052893559e-58f", 0x56b437cb); - assert_fv("5651646798612340020342016480711657876794350448612937515377.9168246981516387681761572917171942006699787e-59f", 0x3d677dd0); - assert_fv("9920578131676161174790443530861675264397677.9298897711364797852622039984800339792608784984943735243969e-60f", 0x2337009b); - assert_fv("773083616833556658593549571984730208359354235112578463650681192940657183241877681935448191944901247.89e-61f", 0x7e68a432); - assert_fv("2033872902291318819533658587926929937970401.2710959140326461152715255744673385110438972744899770478990e-62f", 0x1ec01808); - assert_fv("187092483404158261273309563886869696953860711517177634623418295140717591217501786553686967011911820.16e-64f", 0x78669bfa); - assert_fv("2843972520012909619618738412924946858506071364050969520790130469.6564183442705573933043388503553983971e-65f", 0x3ce8fa6d); - assert_fv("-3167920328730245416675918872510698123649747.0197448975566104570425035214683779103358421115774091455906e-50f", 0xb3080fa7); - assert_fv("-249783215287991700609206429881709801001059982096210257339614200145202268010193890852422414.62355820475e-51f", 0xff3bea7f); - assert_fv("-595183737107507236040047726078083314040101307668270206140872419978091190366856.11220746910898255645599e-52f", 0xea44ee06); - assert_fv("-76819055572958908908607180318192579908.390064325560944297766190914856442196219533847993990033771839484e-53f", 0xa65d6a75); - assert_fv("-27345066113712877639414.541470675499025388433402041564189159881719693776708548924312662738304564834039e-54f", 0x8b0dfbd4); - assert_fv("-33032341693472383071581693183829884769518416411858558965420124046526065005700875289505024365725.789831e-55f", 0xff800000); - assert_fv("-144838624389437451088216359460489896355625182866645852138515761586784620125451689.90858677185938302644e-56f", 0xe7995a96); - assert_fv("-1356331371666722278822170915515168300915990871570040096122323.9185339731198946122395984885562887448632e-57f", 0xc4a98a9b); - assert_fv("-481368822079.99377857759657142688225728589006283892623850921214860803523325061029017834391308715239965e-58f", 0x80000000); - assert_fv("-328927944008110773435372946622163902619777716329705814144015708892316987428223087782359207849.51398513e-59f", 0xf7222c8b); - assert_fv("-138990787136028150208892325935327339723353326461208910600975202859048967812893925.44445941489312845003e-60f", 0xe0f11c4f); - assert_fv("-5454982431776267562255226645310.5758635946084875446154247217806906896424895239254678744420070591539413e-62f", 0x8b8d9e94); - assert_fv("-7205166253751011752189102789303264557408717676074302058856048773986127628410969035.9395997342494195396e-63f", 0xdec7fbc9); - assert_fv("-76933070199318869703378099651132727452672819706738782198961.716339105735432559476593460976546182796211e-64f", 0xb7011281); - assert_fv("-69815358581004637306585691976110578.931405491842086993008950203869116986032671112399645247532546220655e-65f", 0x8d629055); - assert_fv("98585095200858662623172109812592194390466085532382422008251486501034693337558513031.728752945622991068e-50f", 0x76426cc1); - assert_fv("5828287163094775912411337236864724362220863628656245516202546791812208403134276.2809772091183990274580e-51f", 0x6d96a85f); - assert_fv("2321582528980626314150426320947796.6467623526449609344068309566440479069943519742557347153898972731127e-52f", 0x20890ac3); - assert_fv("45441459176204422475664296033326329306630846371661525342305910948893346823833434302.897692455665502690e-53f", 0x70b7895e); - assert_fv("6588285048239226609292976685606151250201723644852757905169505395902840054643439268369554685080.2089864e-54f", 0x7f800000); - assert_fv("3638325373758624145711360240722911800409773984086051892577414.9387593526319359164917949216603153637139e-55f", 0x48b1a711); - assert_fv("157161124239341177562333192441817129469215938306464651694424554880586120257624362357.12065144506672574e-56f", 0x6ca28034); - assert_fv("241905151340252237180786532261509807410236875656094964672084428810061698136073872069394740775.24621559e-57f", 0x7a3a5b61); - assert_fv("805541201256125470668808662849457377924454.00798030349696337172702837631531003173291072937104425613066e-58f", 0x24b9bec2); - assert_fv("26191006575120724407027263633197095144.302297603710709427952415578372900039789985293666773813098089991e-59f", 0x1b9e509f); - assert_fv("334248714753740243656373238860.26727975106198590013651491584373845537341150091339183479598424578069179e-60f", 0x0cd8f098); - assert_fv("393163673550273526719049057584623433332569466099637074254409308441944439849518880640.39571919379112359e-61f", 0x65053583); - assert_fv("9039430282399729236759865263337418773083039689933360384179971345640578359369894842718733364819862.2745e-62f", 0x798b4644); - assert_fv("10034574499971968090115711839949047518183608.052227930508531375816452754886683893636091422183921192827e-65f", 0x1af29f02); +def testFloatVal(t: NumberParserTester) { + def FV = t.assert_fv; + + FV("0f", 0x00000000); + FV("1f", 0x3F800000); + FV("2f", 0x40000000); + FV("3f", 0x40400000); + FV("4f", 0x40800000); + FV("5f", 0x40A00000); + FV("6f", 0x40C00000); + FV("7f", 0x40E00000); + FV("8f", 0x41000000); + FV("9f", 0x41100000); + FV("10f", 0x41200000); + + FV("1e0f", 0x3F800000); + FV("2e0f", 0x40000000); + FV("3e0f", 0x40400000); + FV("4e0f", 0x40800000); + + FV("1e+0f", 0x3F800000); + FV("2e+0f", 0x40000000); + FV("3e+0f", 0x40400000); + FV("4e+0f", 0x40800000); + + FV("1e-0f", 0x3F800000); + FV("2e-0f", 0x40000000); + FV("3e-0f", 0x40400000); + FV("4e-0f", 0x40800000); + + FV("1e1f", 0x41200000); + FV("2e1f", 0x41A00000); + FV("3e1f", 0x41F00000); + FV("4e1f", 0x42200000); + + FV("-1e1f", 0xC1200000); + FV("-2e1f", 0xC1A00000); + FV("-3e1f", 0xC1F00000); + FV("-4e1f", 0xC2200000); + + FV("7e2f", 0x442F0000); + FV("8e3f", 0x45FA0000); + FV("9e4f", 0x47AFC800); + + FV("-5e5f", 0xC8F42400); + FV("-3e6f", 0xCA371B00); + FV("-6e7f", 0xCC64E1C0); + + FV("123F", 0x42F60000); + FV("2345F", 0x45129000); + FV("34567F", 0x47070700); + FV("456789F", 0x48DF0AA0); + + FV("16777214f", 0x4B7FFFFE); + FV("16777215f", 0x4B7FFFFF); + FV("16777216f", 0x4B800000); + + FV("-33554430f", 0xCBFFFFFF); + FV("-33554431f", 0xCC000000); + FV("-33554432f", 0xCC000000); + FV("-33554433f", 0xCC000000); + FV("-33554434f", 0xCC000000); + FV("-33554435f", 0xCC000001); + + FV("-335544331f", 0xCDA00000); + FV("-335544342f", 0xCDA00001); + FV("-335544353f", 0xCDA00001); + + FV("-3355443316f", 0xCF480000); + FV("-3355443427f", 0xCF480001); + FV("-3355443538f", 0xCF480001); + + FV("-3.355443316e9f", 0xCF480000); + FV("-3.355443427e9f", 0xCF480001); + FV("-3.355443538e9f", 0xCF480001); + + FV("33554433160f", 0x50FA0001); + FV("33554434272f", 0x50FA0001); + FV("33554435384f", 0x50FA0002); + FV("33e12f", 0x55F01B4A); + FV("44e13f", 0x57C816BE); + FV("55e14f", 0x599C51C4); + FV("66e15f", 0x5B6A7AA6); + FV("77e16f", 0x5D2AF96F); + FV("88e17f", 0x5EF43FC3); + FV("99e18f", 0x60ABBCD5); + + FV("3.3554433160e10f", 0x50FA0001); + FV("33.554433160e9f", 0x50FA0001); + FV("335.54433160e8f", 0x50FA0001); + FV("3355.4433160e7f", 0x50FA0001); + FV("33554.433160e6f", 0x50FA0001); + FV("335544.33160e5f", 0x50FA0001); + FV("3355443.3160e4f", 0x50FA0001); + FV("33554433.160e3f", 0x50FA0001); + FV("335544331.60e2f", 0x50FA0001); + FV("3355443316.0e1f", 0x50FA0001); + + FV("3.3e13f", 0x55F01B4A); + FV("4.4e14f", 0x57C816BE); + FV("5.5e15f", 0x599C51C4); + FV("6.6e16f", 0x5B6A7AA6); + FV("7.7e17f", 0x5D2AF96F); + FV("8.8e18f", 0x5EF43FC3); + FV("9.9e19f", 0x60ABBCD5); + + FV("3000000000000000000000000000000f", 0x72177617); + FV("3e30f", 0x72177617); + + FV("7e20f", 0x6217C9CE); + FV("7e21f", 0x63BDBC42); + FV("7e22f", 0x656D2B52); + FV("7e23f", 0x67143B13); + FV("7e24f", 0x68B949D8); + FV("7e25f", 0x6A679C4E); + FV("7e26f", 0x6C10C1B1); + FV("7e27f", 0x6DB4F21D); + FV("7e28f", 0x6F622EA5); + FV("7e29f", 0x710D5D27); + FV("7e30f", 0x72B0B471); + FV("7e31f", 0x745CE18D); + FV("7e32f", 0x760A0CF8); + FV("7e33f", 0x77AC9036); + FV("7e34f", 0x7957B443); + FV("7e35f", 0x7B06D0AA); + FV("7e36f", 0x7CA884D5); + FV("7e37f", 0x7E52A60A); + FV("7e38f", 0x7F800000); + FV("7e39f", 0x7F800000); + FV("7e40f", 0x7F800000); + FV("7e41f", 0x7F800000); + FV("7e42f", 0x7F800000); + + FV("7.0e20f", 0x6217C9CE); + FV("7.00e21f", 0x63BDBC42); + FV("7.000e22f", 0x656D2B52); + FV("7.0000e23f", 0x67143B13); + + FV("71234567890f", 0x5184AF4A); + FV("712345678901234567890f", 0x621A7721); + FV("7123456789012345678901234567890f", 0x72B3D243); + FV("71234567890123456789012345678901234567890f", 0x7F800000); + + FV("0.1e1f", 0x3F800000); + FV("0.01e2f", 0x3F800000); + FV("0.001e3f", 0x3F800000); + FV("0.0001e4f", 0x3F800000); + FV("0.00001e5f", 0x3F800000); + FV("0.000001e6f", 0x3F800000); + + FV("0e-0f", 0x00000000); + FV("0e-2f", 0x00000000); + FV("0e-32f", 0x00000000); + FV("-0e-0f", 0x80000000); + FV("-0e-32f", 0x80000000); + + FV("0.0e-0f", 0x00000000); + FV("0.00e-2f", 0x00000000); + FV("0.000e-32f", 0x00000000); + FV("-0.0000e-0f", 0x80000000); + FV("-0.00000e-32f", 0x80000000); + + FV("0.25f", 0x3e800000); + FV("0.1f", 0x3dcccccd); + FV("0.2f", 0x3e4ccccd); + FV("0.3f", 0x3e99999a); + FV("0.4f", 0x3ecccccd); + FV("0.5f", 0x3f000000); + FV("0.6f", 0x3f19999a); + FV("0.7f", 0x3f333333); + FV("0.8f", 0x3f4ccccd); + FV("0.9f", 0x3f666666); + FV("1.2f", 0x3f99999a); + FV("1.3f", 0x3fa66666); + FV("1.4f", 0x3fb33333); + FV("1.5f", 0x3fc00000); + FV("1.6f", 0x3fcccccd); + FV("1.7f", 0x3fd9999a); + FV("1.8f", 0x3fe66666); + FV("1.9f", 0x3ff33333); + FV("0.77f", 0x3f451eb8); + FV("-0.888f", 0xbf6353f8); + FV("0.055f", 0x3d6147ae); + FV("-0.003f", 0xbb449ba6); + FV("0.000256f", 0x398637bd); + + FV("0.00000000000000000000000000000000000000001e35f", 0x358637bd); + FV("0.00000000000000000000000000000000000000001e36f", 0x3727c5ac); + FV("0.00000000000000000000000000000000000000001e37f", 0x38d1b717); + FV("0.00000000000000000000000000000000000000001e38f", 0x3a83126f); + FV("0.00000000000000000000000000000000000000001e39f", 0x3c23d70a); + FV("0.00000000000000000000000000000000000000001e40f", 0x3dcccccd); + FV("0.00000000000000000000000000000000000000001e41f", 0x3f800000); + FV("0.00000000000000000000000000000000000000001e42f", 0x41200000); + FV("0.00000000000000000000000000000000000000001e43f", 0x42c80000); + + FV("185.72412200915e1f", 0x44e827b8); + FV("4.7302596179249e2f", 0x43ec8353); + FV("5615494048341.8e5f", 0x5cf960c7); + FV("7342260514584.7e7f", 0x607ebc60); + FV("7.9884410687136e8f", 0x4e3e7593); + FV("294685302509.94e9f", 0x617f9948); + FV("7620831416.3202e10f", 0x6084334a); + FV("-35516375.575608e2f", 0xcf53b1b0); + FV("-92.774285393734e3f", 0xc7b53325); + FV("-137.59529062660e4f", 0xc9a7f687); + FV("-43477.918874861e6f", 0xd121f7c6); + FV("-29206538413.631e7f", 0xdc81b3fd); + FV("-79487457.048481e8f", 0xd9e1eabd); + FV("-2129829.7340178e9f", 0xd8f22234); + FV("-131565661.09411e10f", 0xdd921136); + FV("27.188681084028e1f", 0x4387f183); + FV("22.719239557501e2f", 0x450dfec9); + FV("43761692.688262e3f", 0x51230667); + FV("921426.31951767e4f", 0x50094da0); + FV("17386950816.168e5f", 0x58c5aab0); + FV("82181777.925024e6f", 0x56957cdf); + FV("72.930837573463e8f", 0x4fd959d0); + FV("180654568.93720e9f", 0x5c207418); + FV("807024110.94844e10f", 0x5edffe83); + FV("-209792113238.85e1f", 0xd3f43aec); + FV("-4588377705.8484e2f", 0xd2d5a9ba); + FV("-81510.845965265e3f", 0xcc9b7838); + FV("-33143209.696364e4f", 0xd29a55c9); + FV("-479110.62517607e5f", 0xd1327b8d); + FV("-773507.38820913e7f", 0xd4e11ecb); + FV("-168397810346.80e8f", 0xdf69b2ec); + FV("-13.005293084012e9f", 0xd041cb42); + FV("-8537194723170.0e10f", 0xe590a02e); + FV("6254865735.8453e1f", 0x5169030c); + FV("1731230.5098861e2f", 0x4d251a5f); + FV("57173556.438299e3f", 0x5154fcf4); + FV("2774761115603.8e5f", 0x5c7672c3); + FV("8.6915836797536e6f", 0x4b049f80); + FV("180.91048751753e7f", 0x4ed7a980); + FV("8.5644244527073e8f", 0x4e4c3119); + FV("2.6993198547353e9f", 0x4f20e45a); + + FV("9516.6979653034286801107378e21f", 0x68fbe7a7); + FV("5458099002.0985476800540042e22f", 0x742c3a2c); + FV("167336613270.16623700965846e24f", 0x7a00e954); + FV("-2136634670700.0542637549382e22f", 0xf883ae27); + FV("-554143678.86087209690274809e23f", 0xf42edb5f); + FV("1033335001801.3347779336833e20f", 0x74a30811); + FV("61.216566195503108036373989e22f", 0x6701a191); + FV("-99831.029760844545783406252e20f", 0xe9042012); + FV("-681.63190203986626280183378e21f", 0xe7105757); + FV("433562013897498235.44047013e20f", 0x7e027867); + FV("623.74999688324855696644183e22f", 0x68a51af2); + FV("31.888863826233584205293094e23f", 0x6828d178); + FV("631449247027208571870.94688e20f", 0x7f800000); + FV("-2336793464514665.3189416421e25f", 0xff800000); + + FV("6500.8975612e-20f", 0x2495e687); + FV("7279324.9022e-21f", 0x280321f6); + FV("7249213.5844e-22f", 0x2650f1c1); + FV("22.118349986e-23f", 0x1b85b27d); + FV("1680.4913394e-24f", 0x1cfdf2dc); + FV("7028517.9322e-25f", 0x214f71fb); + FV("-2815.9283089e-20f", 0xa401dc9d); + FV("-915167294.09e-21f", 0xab80cc60); + FV("-38.790096392e-22f", 0x9d928b7b); + FV("-7219413819.7e-23f", 0xa9a29116); + FV("-2789.8602027e-24f", 0x9d52cbbf); + FV("-9209.7866623e-25f", 0x9c8b2ca3); + FV("63695579.824e-20f", 0x2b334981); + FV("886683.19190e-21f", 0x267f91ac); + FV("5075558065.7e-22f", 0x2b0edd40); + FV("70620106.039e-23f", 0x264b8c71); + FV("2098.0362120e-24f", 0x1d1e85ec); + FV("8222952790.8e-25f", 0x266d02af); + FV("-35.110694492e-20f", 0xa0cf41c8); + FV("-4702.9959135e-21f", 0xa2ad828a); + FV("-4.1206162546e-22f", 0x9bf91373); + FV("-831237336.02e-23f", 0xa815be0e); + FV("-88522172.984e-24f", 0xa4cc1e45); + FV("-260.47278336e-25f", 0x99fbe9f0); + FV("25166.643208e-20f", 0x25911369); + FV("403855.64762e-21f", 0x25e8ce93); + FV("822158130.23e-22f", 0x29b92230); + FV("895.94617781e-23f", 0x1e293d4c); + FV("2.4165007388e-24f", 0x183af7ba); + FV("4980.6450018e-25f", 0x1c1687e0); + + FV("9898221099373760452432004214463178514232396176102051629.3262574807486478523095921804235158439917196128e-50f", 0x47c1531b); + FV("628195315932329837240373787952.72272571256058789639887141320206244957439104308759971954412551804132921e-51f", 0x1c3ddc42); + FV("71266646067357792083159028241532231341651553017449710170753835622762883652074590114.460446334264986207e-52f", 0x72b3e6fe); + FV("28860920170358551844751866177713959174937116163976699335122616309803326883480.527051473550462029339773e-53f", 0x66747625); + FV("9622770093766661066278657025766503317565584236268310447676869076424839331989741.5796060568871094140562e-55f", 0x674bc524); + FV("265059469745793762195083470727223228095957648623578506113392626417719626085374.46907942618002358159462e-56f", 0x630fb064); + FV("49151520377435578293480798031909732997983740857622296326806327690.305186320393056401832977546941044141e-57f", 0x4c3b7f88); + FV("322911015799560802930301140645012892848917166.88248536301678575194449943615925118039659556582806602248e-58f", 0x29116d1b); + FV("13873755635452835866707032152757462841822.712751691774788369373846175929823920996008508002750362746373e-59f", 0x2023cada); + FV("8018751607103526301813006647748254211.1140044261280317353790270432336986888744019868305924628456188248e-60f", 0x191b1aef); + FV("7487504180538780603062658120149412332957864670.2950943988098802107524184756806578174747717265670839746e-61f", 0x2657d008); + FV("331576089996596550440770874834375147287044.33180482729350555696144717534561721903859117273298097188819e-63f", 0x1bc86cea); + FV("44750714092811261827250288422280157129504950464891031138004994464977889298375.802767929724780226789236e-64f", 0x54823de1); + FV("2858360453254539933790224661576666503622724366236774850710336836832182398286958789409296395458.1261086e-65f", 0x6eb8b79b); + FV("-822092086175131254660938944127449900101107982289741796799361503261934.18912996456493577368044640124852e-50f", 0xdee42d28); + FV("-556952.16536595859396418343473873745152120725837356500162613770304555849322221028446221530060574131323e-51f", 0x80000000); + FV("-432254910899854160088452528846111672261083266509683694352541924739507680094422.77595046830292927956714e-52f", 0xea0f056a); + FV("-6762115379473203174343553921760256089733466396823666464993838920100024.9529392317932325795475969719535e-53f", 0xdb703d15); + FV("-77.832217639202604332883124500037408421959246205016607253096265760102129864551793910444026581472227980e-55f", 0x80000000); + FV("-2526263342524521713528678061066.5502393118249575094303713039074280708583352786881678039676444187783916e-56f", 0x94fa3063); + FV("-540042.03832322042193603594331928821695308216140823166666083764351616614258916825152779791177618028106e-57f", 0x80000000); + FV("-32844504597231239494006292226103444278552871786177891546092488288111683180.400796934054330320697151892e-58f", 0xd93ab30b); + FV("-31743202577835485285450956.365482906258478283984248675182829399837770759292732785008301497049865976606e-59f", 0x87d2f843); + FV("-556.27647871502760621103455978886480727434642043275681576287584797088520757896508433660154982640272659e-60f", 0x80000000); + FV("-299607339670536189315991837914784538609222877289559629399303164579544062025.55608521409424987618735777e-61f", 0xd5d9fe37); + FV("-872801179392882698780532203412475719175553611302194508037283048431667082237.20360656175107630127091915e-62f", 0xd4fe04c1); + FV("-4.8048389681418483617357741795408082397543418570485194588201355408796368536165517170081678709148840331e-63f", 0x80000000); + FV("-556100963915704027.49432288135667720637157077217593156414811833687548305451472542756471127476670224321e-64f", 0x80000000); + FV("-73660138684932314536696203847517810.373998118985404150059245249755490698291199708251048494127776078956e-65f", 0x8d6f0a73); + FV("568056432918239059248149085.96819756672510287709803861737344173298231655640846996435640729201170299587e-51f", 0x172fce11); + FV("36140659944573457531762624505812900541925859495001914598972214192082681577668995551524331.991583569595e-53f", 0x7a8b3571); + FV("949747474795293409361155500215507691636378196352081379090897304735767877037236955167683750.76436118970e-54f", 0x7b36ea2a); + FV("1324270968072772854107680607.6928979760738098592175225757103046994542065558106581040519263108037655351e-55f", 0x1127df0d); + FV("82754011555866363745359908347841407395996.380559697904199831038580137213390177416920406205516485486713e-56f", 0x266e85af); + FV("990758633065384206565348341606181296081640516129314468002885226245431880.31507668544714275742052893559e-58f", 0x56b437cb); + FV("5651646798612340020342016480711657876794350448612937515377.9168246981516387681761572917171942006699787e-59f", 0x3d677dd0); + FV("9920578131676161174790443530861675264397677.9298897711364797852622039984800339792608784984943735243969e-60f", 0x2337009b); + FV("773083616833556658593549571984730208359354235112578463650681192940657183241877681935448191944901247.89e-61f", 0x7e68a432); + FV("2033872902291318819533658587926929937970401.2710959140326461152715255744673385110438972744899770478990e-62f", 0x1ec01808); + FV("187092483404158261273309563886869696953860711517177634623418295140717591217501786553686967011911820.16e-64f", 0x78669bfa); + FV("2843972520012909619618738412924946858506071364050969520790130469.6564183442705573933043388503553983971e-65f", 0x3ce8fa6d); + FV("-3167920328730245416675918872510698123649747.0197448975566104570425035214683779103358421115774091455906e-50f", 0xb3080fa7); + FV("-249783215287991700609206429881709801001059982096210257339614200145202268010193890852422414.62355820475e-51f", 0xff3bea7f); + FV("-595183737107507236040047726078083314040101307668270206140872419978091190366856.11220746910898255645599e-52f", 0xea44ee06); + FV("-76819055572958908908607180318192579908.390064325560944297766190914856442196219533847993990033771839484e-53f", 0xa65d6a75); + FV("-27345066113712877639414.541470675499025388433402041564189159881719693776708548924312662738304564834039e-54f", 0x8b0dfbd4); + FV("-33032341693472383071581693183829884769518416411858558965420124046526065005700875289505024365725.789831e-55f", 0xff800000); + FV("-144838624389437451088216359460489896355625182866645852138515761586784620125451689.90858677185938302644e-56f", 0xe7995a96); + FV("-1356331371666722278822170915515168300915990871570040096122323.9185339731198946122395984885562887448632e-57f", 0xc4a98a9b); + FV("-481368822079.99377857759657142688225728589006283892623850921214860803523325061029017834391308715239965e-58f", 0x80000000); + FV("-328927944008110773435372946622163902619777716329705814144015708892316987428223087782359207849.51398513e-59f", 0xf7222c8b); + FV("-138990787136028150208892325935327339723353326461208910600975202859048967812893925.44445941489312845003e-60f", 0xe0f11c4f); + FV("-5454982431776267562255226645310.5758635946084875446154247217806906896424895239254678744420070591539413e-62f", 0x8b8d9e94); + FV("-7205166253751011752189102789303264557408717676074302058856048773986127628410969035.9395997342494195396e-63f", 0xdec7fbc9); + FV("-76933070199318869703378099651132727452672819706738782198961.716339105735432559476593460976546182796211e-64f", 0xb7011281); + FV("-69815358581004637306585691976110578.931405491842086993008950203869116986032671112399645247532546220655e-65f", 0x8d629055); + FV("98585095200858662623172109812592194390466085532382422008251486501034693337558513031.728752945622991068e-50f", 0x76426cc1); + FV("5828287163094775912411337236864724362220863628656245516202546791812208403134276.2809772091183990274580e-51f", 0x6d96a85f); + FV("2321582528980626314150426320947796.6467623526449609344068309566440479069943519742557347153898972731127e-52f", 0x20890ac3); + FV("45441459176204422475664296033326329306630846371661525342305910948893346823833434302.897692455665502690e-53f", 0x70b7895e); + FV("6588285048239226609292976685606151250201723644852757905169505395902840054643439268369554685080.2089864e-54f", 0x7f800000); + FV("3638325373758624145711360240722911800409773984086051892577414.9387593526319359164917949216603153637139e-55f", 0x48b1a711); + FV("157161124239341177562333192441817129469215938306464651694424554880586120257624362357.12065144506672574e-56f", 0x6ca28034); + FV("241905151340252237180786532261509807410236875656094964672084428810061698136073872069394740775.24621559e-57f", 0x7a3a5b61); + FV("805541201256125470668808662849457377924454.00798030349696337172702837631531003173291072937104425613066e-58f", 0x24b9bec2); + FV("26191006575120724407027263633197095144.302297603710709427952415578372900039789985293666773813098089991e-59f", 0x1b9e509f); + FV("334248714753740243656373238860.26727975106198590013651491584373845537341150091339183479598424578069179e-60f", 0x0cd8f098); + FV("393163673550273526719049057584623433332569466099637074254409308441944439849518880640.39571919379112359e-61f", 0x65053583); + FV("9039430282399729236759865263337418773083039689933360384179971345640578359369894842718733364819862.2745e-62f", 0x798b4644); + FV("10034574499971968090115711839949047518183608.052227930508531375816452754886683893636091422183921192827e-65f", 0x1af29f02); // subnormal cases - assert_fv( "1e-35f", 0x0554ad2e); - assert_fv("-1e-36f", 0x83aa2425); - assert_fv( "1e-37f", 0x02081cea); - assert_fv("-1e-38f", 0x806ce3ee); - assert_fv( "1e-40f", 0x000116c2); - assert_fv("-1e-41f", 0x80001be0); - assert_fv( "1e-43f", 0x00000047); - assert_fv("-1e-44f", 0x80000007); - assert_fv( "1e-46f", 0x00000000); - assert_fv("-1e-47f", 0x80000000); + FV( "1e-35f", 0x0554ad2e); + FV("-1e-36f", 0x83aa2425); + FV( "1e-37f", 0x02081cea); + FV("-1e-38f", 0x806ce3ee); + FV( "1e-40f", 0x000116c2); + FV("-1e-41f", 0x80001be0); + FV( "1e-43f", 0x00000047); + FV("-1e-44f", 0x80000007); + FV( "1e-46f", 0x00000000); + FV("-1e-47f", 0x80000000); // subnormal rounding - assert_fv("1.9999999e-40f", 0x00022d85); - assert_fv("1.9999999e-41f", 0x000037c0); - assert_fv("1.9999999e-42f", 0x00000593); - assert_fv("1.9999999e-43f", 0x0000008f); - assert_fv("1.9999999e-44f", 0x0000000e); - assert_fv("1.9999999e-45f", 0x00000001); - assert_fv("1.9999999e-46f", 0x00000000); - assert_fv("1.9999999e-47f", 0x00000000); - assert_fv("1.9999999e-48f", 0x00000000); - - - assert_fv("1e-39f", 0x000ae398); - assert_fv("1e-42f", 0x000002ca); - assert_fv("1e-45f", 0x00000001); - assert_fv("-7586490734715.1926218767061514520801227997463798643716440736293925036482996157576791729202733568107336e-54f", 0x80001526); - assert_fv("-36865440730740277.663444233165954623857074362386941637758888485473771724556558084890439348557435782248e-61f", 0x80000003); - - assert_fv("-9.223372036854776E18f", 0xdf000000); - assert_fv("-9.2233714870989619E18f", 0xdeffffff); -} - -def assert_dv(str: string, bits: u64) { - var p = NumberParser.new(str); - if (!p.parse()) return TEST.error1("\"%s\" did not parse", str); - if (!p.is_float) return TEST.error1("\"%s\" should have .is_float=true", str); - if (p.vtype != Float.FLOAT64) return TEST.error1("\"%s\" should be of type double", str); - if (!Float64Val.?(p.val)) return TEST.error1("\"%s\" should be Float64Val", str); - var got = Float64Val.!(p.val).bits; - if (bits != got) { - var buf = StringBuilder.new(); - buf.put1("\"%s\" should be ", str); - buf.putx(long.view(bits)); - buf.puts(", got "); - buf.putx(long.view(got)); - return TEST.error(buf.toString()); - } + FV("1.9999999e-40f", 0x00022d85); + FV("1.9999999e-41f", 0x000037c0); + FV("1.9999999e-42f", 0x00000593); + FV("1.9999999e-43f", 0x0000008f); + FV("1.9999999e-44f", 0x0000000e); + FV("1.9999999e-45f", 0x00000001); + FV("1.9999999e-46f", 0x00000000); + FV("1.9999999e-47f", 0x00000000); + FV("1.9999999e-48f", 0x00000000); + + + FV("1e-39f", 0x000ae398); + FV("1e-42f", 0x000002ca); + FV("1e-45f", 0x00000001); + FV("-7586490734715.1926218767061514520801227997463798643716440736293925036482996157576791729202733568107336e-54f", 0x80001526); + FV("-36865440730740277.663444233165954623857074362386941637758888485473771724556558084890439348557435782248e-61f", 0x80000003); + + FV("-9.223372036854776E18f", 0xdf000000); + FV("-9.2233714870989619E18f", 0xdeffffff); } -def testDoubleVal() { - assert_dv("0d", 0x0000000000000000); - assert_dv("1d", 0x3FF0000000000000); - assert_dv("2d", 0x4000000000000000); - assert_dv("3d", 0x4008000000000000); - assert_dv("4d", 0x4010000000000000); - - assert_dv("-0d", 0x8000000000000000); - assert_dv("-1d", 0xBFF0000000000000); - assert_dv("-2d", 0xC000000000000000); - assert_dv("-3d", 0xC008000000000000); - assert_dv("-4d", 0xC010000000000000); - - assert_dv("5d", 0x4014000000000000); - assert_dv("6d", 0x4018000000000000); - assert_dv("7d", 0x401C000000000000); - assert_dv("8d", 0x4020000000000000); - assert_dv("9d", 0x4022000000000000); - assert_dv("10d", 0x4024000000000000); - assert_dv("11d", 0x4026000000000000); - - assert_dv("1e0", 0x3FF0000000000000); - assert_dv("1e+0", 0x3FF0000000000000); - assert_dv("1e-0", 0x3FF0000000000000); - assert_dv("3e0", 0x4008000000000000); - assert_dv("3e+0", 0x4008000000000000); - assert_dv("3e-0", 0x4008000000000000); - - assert_dv("1e1d", 0x4024000000000000); - assert_dv("1e+1d", 0x4024000000000000); - assert_dv("3e1D", 0x403E000000000000); - assert_dv("3e+1D", 0x403E000000000000); - - assert_dv("-5e5", 0xC11E848000000000); - assert_dv("-3e6", 0xC146E36000000000); - assert_dv("-9e9", 0xC200C388D0000000); - - assert_dv("-5.0e5", 0xC11E848000000000); - assert_dv("-5.00e5", 0xC11E848000000000); - assert_dv("-5.000e5", 0xC11E848000000000); - assert_dv("-5.0000e5", 0xC11E848000000000); - assert_dv("-5.00000e5", 0xC11E848000000000); - - assert_dv("2251799813685247d", 0x431FFFFFFFFFFFFC); - assert_dv("2251799813685248d", 0x4320000000000000); - assert_dv("2251799813685249d", 0x4320000000000002); - assert_dv("2251799813685250d", 0x4320000000000004); - - assert_dv("-2251799813685250d", 0xC320000000000004); - assert_dv("-2251799813685251d", 0xC320000000000006); - - assert_dv("4503599627370495d", 0x432FFFFFFFFFFFFE); - assert_dv("4503599627370496d", 0x4330000000000000); - assert_dv("4503599627370497d", 0x4330000000000001); - - assert_dv("-4503599627370497d", 0xC330000000000001); - assert_dv("-4503599627370498d", 0xC330000000000002); - - assert_dv("9007199254740991d", 0x433FFFFFFFFFFFFF); - assert_dv("9007199254740992d", 0x4340000000000000); - assert_dv("9007199254740993d", 0x4340000000000000); - assert_dv("9007199254740994d", 0x4340000000000001); - assert_dv("9007199254740995d", 0x4340000000000002); - - assert_dv("18014398509481982d", 0x434FFFFFFFFFFFFF); - assert_dv("18014398509481983d", 0x4350000000000000); - assert_dv("18014398509481984d", 0x4350000000000000); - assert_dv("18014398509481985d", 0x4350000000000000); - assert_dv("18014398509481986d", 0x4350000000000000); - - assert_dv("2.251799813685247e15d", 0x431FFFFFFFFFFFFC); - assert_dv("22.51799813685247e14d", 0x431FFFFFFFFFFFFC); - assert_dv("225.1799813685247e13d", 0x431FFFFFFFFFFFFC); - assert_dv("2251.799813685247e12d", 0x431FFFFFFFFFFFFC); - assert_dv("22517.99813685247e11d", 0x431FFFFFFFFFFFFC); - assert_dv("225179.9813685247e10d", 0x431FFFFFFFFFFFFC); - assert_dv("2251799.813685247e9d", 0x431FFFFFFFFFFFFC); - assert_dv("22517998.13685247e8d", 0x431FFFFFFFFFFFFC); - assert_dv("225179981.3685247e7d", 0x431FFFFFFFFFFFFC); - assert_dv("2251799813.685247e6d", 0x431FFFFFFFFFFFFC); - assert_dv("22517998136.85247e5d", 0x431FFFFFFFFFFFFC); - assert_dv("225179981368.5247e4d", 0x431FFFFFFFFFFFFC); - assert_dv("2251799813685.247e3d", 0x431FFFFFFFFFFFFC); - assert_dv("22517998136852.47e2d", 0x431FFFFFFFFFFFFC); - - assert_dv("5e16", 0x4366345785D8A000); - assert_dv("5e17", 0x439BC16D674EC800); - assert_dv("5e18", 0x43D158E460913D00); - assert_dv("5e19", 0x4405AF1D78B58C40); - assert_dv("5e20", 0x443B1AE4D6E2EF50); - assert_dv("5e21", 0x4470F0CF064DD592); - - assert_dv("7e305", 0x7F6FE60E8164FD06); - assert_dv("7e306", 0x7FA3EFC910DF1E24); - assert_dv("7e307", 0x7FD8EBBB5516E5AD); - assert_dv("7e308", 0x7FF0000000000000); - assert_dv("7e309", 0x7FF0000000000000); - - assert_dv("7.0e305", 0x7F6FE60E8164FD06); - assert_dv("7.1e305", 0x7F702D5B787A87A2); - assert_dv("-7.01e305", 0xFF6FF1B8F2F3653F); - assert_dv("7.0e306", 0x7FA3EFC910DF1E24); - assert_dv("7.0e307", 0x7FD8EBBB5516E5AD); - assert_dv("7.0e308", 0x7FF0000000000000); - - assert_dv("0.1e1", 0x3FF0000000000000); - assert_dv("0.01e2", 0x3FF0000000000000); - assert_dv("0.001e3", 0x3FF0000000000000); - assert_dv("0.0001e4", 0x3FF0000000000000); - assert_dv("0.000000000000000000000000000000000000000000000000000001e54", 0x3FF0000000000000); - - assert_dv("0.18014398509481982e17d", 0x434FFFFFFFFFFFFF); - assert_dv("0.0000018014398509481982e22d", 0x434FFFFFFFFFFFFF); - assert_dv("-0.000000000018014398509481982e27d", 0xC34FFFFFFFFFFFFF); - - assert_dv("0e-0d", 0x0000000000000000); - assert_dv("0e-2", 0x0000000000000000); - assert_dv("0e-32d", 0x0000000000000000); - assert_dv("-0e-0d", 0x8000000000000000); - assert_dv("-0e-32d", 0x8000000000000000); - - assert_dv("0.0e-0d", 0x0000000000000000); - assert_dv("0.00e-2", 0x0000000000000000); - assert_dv("0.000e-32d", 0x0000000000000000); - assert_dv("-0.0000e-0d", 0x8000000000000000); - assert_dv("-0.00000e-32d", 0x8000000000000000); - - assert_dv("0.1", 0x3fb999999999999a); - assert_dv("-0.2", 0xbfc999999999999a); - assert_dv("-0.3", 0xbfd3333333333333); - assert_dv("0.5", 0x3fe0000000000000); - assert_dv("-0.7", 0xbfe6666666666666); - assert_dv("0.9", 0x3feccccccccccccd); - assert_dv("1.1", 0x3ff199999999999a); - assert_dv("-1.2", 0xbff3333333333333); - assert_dv("1.3", 0x3ff4cccccccccccd); - assert_dv("1.4", 0x3ff6666666666666); - assert_dv("1.44", 0x3ff70a3d70a3d70a); - assert_dv("2.33", 0x4002a3d70a3d70a4); - assert_dv("4.11", 0x401070a3d70a3d71); - assert_dv("5.55", 0x4016333333333333); - - assert_dv("1.23456789e1", 0x4028b0fcd324d5a2); - assert_dv("1.23456789e2", 0x405edd3c07ee0b0b); - assert_dv("1.23456789e3", 0x40934a4584f4c6e7); - assert_dv("1.23456789e10", 0x4206fee0e1a00000); - assert_dv("1.23456789e-1", 0x3fbf9add3739635f); - assert_dv("1.23456789e-2", 0x3f8948b0f8fab5e6); - assert_dv("1.23456789e-5", 0x3ee9e409301b5a02); - assert_dv("1.23456789e-9", 0x3e1535afdf51cc65); - assert_dv("-1.23456789e-13", 0xbd415fffe53a685d); - assert_dv("1.23456789e-33", 0x3919a416bc24b5d8); - assert_dv("-1.23456789e-67", 0xb20aa08a1f46b961); - assert_dv("5.669823e-60", 0x33a238dc1b6265f2); - assert_dv("7.559823111222e-60", 0x33a84bdc97c884c5); - assert_dv("-1.23456789e-103", 0xaa91b25e1ab9b3dd); - assert_dv("1.23456789e-200", 0x166e3d71f615c1a8); - assert_dv("1.23456789e-300", 0x01aa74fe1c132c0e); - - assert_dv("181.618383758633790582e-10", 0x3e538049c22ae839); - assert_dv("87.2832996973054334182e-11", 0x3e0dfd852e1201b7); - assert_dv("75666880094465730285.3e-12", 0x41920a570060bba0); - assert_dv("97914582937.6148465059e-13", 0x3f840d8b4936fefd); - assert_dv("68671563.8508565834629e-14", 0x3ea70ad7a8b64b1d); - assert_dv("28409978678876922140.9e-15", 0x40dbbe7ea2acba6b); - assert_dv("-935239111910.502280784e-10", 0xc0576187c2cde46d); - assert_dv("-1299655.47142223750168e-11", 0xbeeb4178e0f024f1); - assert_dv("-4819573367496794.55021e-12", 0xc0b2d392c8365752); - assert_dv("-655816518427468.551792e-13", 0xc0506539c8a69060); - assert_dv("-392.680575416282618145e-14", 0xbd914530b318caf2); - assert_dv("-74533874.7002032848397e-15", 0xbe7401edca53895d); - assert_dv("9459803896626232.42941e-10", 0x412cde78c781dbff); - assert_dv("88106218601.0303238072e-11", 0x3fec31a953550239); - assert_dv("64714391942252.7564729e-12", 0x40502db898fb2019); - assert_dv("53684.5675548620838520e-13", 0x3e370eae3d7f3b31); - assert_dv("336.898219180856323863e-14", 0x3d8da246023fda0f); - assert_dv("944929.708957285766454e-15", 0x3e103bd845731e9f); - assert_dv("-70566543.0413272622408e-10", 0xbf7ce77037496e8d); - assert_dv("-849283.932969460431721e-11", 0xbee1cf8ef3110f6b); - assert_dv("-340016581683.942959995e-12", 0xbfd5c2d4e89b892d); - assert_dv("-120653.674896922480273e-13", 0xbe49e901843ecddf); - assert_dv("-267.379643644492056603e-14", 0xbd8784dab48bdecd); - assert_dv("-82.7248210688390866278e-15", 0xbd3748f39a511eae); - assert_dv("33049220.8276802354518e-10", 0x3f6b12ec885cb530); - assert_dv("878783210.598898001485e-11", 0x3f81ff5adbfbd33a); - assert_dv("6156442322083313.73074e-12", 0x40b80c713c052222); - assert_dv("74193516915727671149.0e-13", 0x415c4d75ec42ba6c); - assert_dv("19776517730996757664.6e-14", 0x410824296b217d00); - assert_dv("7.93108569289931314599e-15", 0x3d01dbf5a9fdc6fc); - - assert_dv("52752726596641413536348493.30370e-40", 0x3cf7c1f9acbc66e1); - assert_dv("5606547191.364630149521729408396e-41", 0x397231bcb7c3d99f); - assert_dv("183321504066877177116.5553948957e-42", 0x3b6bb3e83d548a6f); - assert_dv("217573287432098988980122352.9349e-43", 0x3c7915a147bc74f0); - assert_dv("9.811844312068794897773140099585e-44", 0x370181421f47942d); - assert_dv("9476233371718431059094838037.641e-45", 0x3c65d9c7e643b34b); - assert_dv("-359.2724344039193848598221842172e-40", 0xb82873689a71d668); - assert_dv("-43588672818350475573678505952.86e-41", 0xbd5eac3cbae0187c); - assert_dv("-172574948712499593743049315.1743e-42", 0xbca8dee44ea26980); - assert_dv("-24.22433627673339965053032084376e-43", 0xb74b02d35b4927c7); - assert_dv("-58363626.70718161468339162665295e-44", 0xb868d33c75c764f9); - assert_dv("-538637872905.0462041870630977788e-45", 0xb9065fc7c32f78bf); - assert_dv("77374373790467.61591928867200325e-40", 0x3a83282efe5ee499); - assert_dv("256428100.6705829209489842387089e-41", 0x392aa1073887f4e3); - assert_dv("287667153563840388221814.9538149e-42", 0x3c1539e0ff624981); - assert_dv("7061551755.562964326161393668828e-43", 0x390d55213c85a313); - assert_dv("8337908816.915929775460346629687e-44", 0x38dbb51bbe095c02); - assert_dv("2561900570313278296922227.606489e-45", 0x3ba8324ba575d870); - assert_dv("-677842.3251704117879138792739214e-40", 0xb8d68671dc75ca94); - assert_dv("-9346849603125356031236231593.965e-41", 0xbd3a4f1d6cdcbadc); - assert_dv("-560207394713.9608234160433559017e-42", 0xb9a6b986b47ad16c); - assert_dv("-949859044657905112610860628.2289e-43", 0xbc9b60b901a1f026); - assert_dv("-21667.66587764476260511749834445e-44", 0xb7b2e00d0b92bb1c); - assert_dv("-52680480782763740.88984092015124e-45", 0xba10b1f2c78d2add); - assert_dv("197142341156.0351654478288900107e-40", 0x39f8fda27e6e41dc); - assert_dv("9019802903173354831277557498.807e-41", 0x3d396373f51ed006); - assert_dv("50536213180372108209.26912408181e-42", 0x3b4e8c19a7c558a2); - assert_dv("689347678622550189566.3380960156e-43", 0x3b54d591bf6dc0eb); - assert_dv("9114341568048.812943402077656339e-44", 0x397d93e61378e539); - assert_dv("27059543153867578.43760122136206e-45", 0x3a0126a972819425); - - assert_dv("40406306512213302763134258.04011755764507261436810786026634788e-150", 0x261b5a1576db566a); - assert_dv("770.2242232052013798311706780055732764525644530785033814980975e-151", 0x212f83fbb08603fc); - assert_dv("1823630756912269.073168986837224562554585680653715099819306801e-152", 0x238b255c75bc77c5); - assert_dv("-1271095456846779744.122225601260812580676565896049489104229575e-150", 0xa48cdf0d1b9b656e); - assert_dv("-3073834102175485167602790344242519609096709008415176.627638789e-151", 0xab4583aeda112bd4); - assert_dv("-76807041473499918.28219913405738422281004250357007396215643566e-152", 0xa3e1dd4b09f7aab2); - assert_dv("473004324189367674577653220231042060278613271206.6035172291011e-150", 0x2ab0f356cc14f6d9); - assert_dv("738128442461175122909232375959037.6587279938367440226464294523e-151", 0x2767d34d7afb08f5); - assert_dv("6646.255694418556090987919878684243356765130789439879984439008e-152", 0x212b31da656590ea); - assert_dv("-93739030.56901226422587564977689831587524824128343883601115493e-150", 0xa2724a132e420559); - assert_dv("-5493869690922581902633545554553920427552769799448890.539976507e-151", 0xab5339f240d563dd); - assert_dv("-55591683430622647660201338244717381889.07880801706568159681373e-152", 0xa835e77c2d7817a3); - assert_dv("23221685933637335175798730660327806104229.38115631033034318048e-150", 0x292bec4a06ae3709); - assert_dv("198859.6815487332390887724345038286727393742442636440016691442e-151", 0x21afc8d1530b0197); - assert_dv("32122024942792611826720.34599725942530012718344270853097191745e-152", 0x250c801a87cea4ce); - - assert_dv("55334153387763925503651114228820352318.400992904243313136623353042601433e-250", 0x13ddce1944fe3c78); - assert_dv("853317531724299834.06934134094305577516602961382291952631169180845858123e-251", 0x0f8b21b84163ad54); - assert_dv("5676916923311868526902859.5575084363007743978197221809956468259145827961e-252", 0x10c136c213e34bb8); - assert_dv("-70496488926169100251287645.546104934749284973675351784247564018076851003e-250", 0x9164e0186e67ac52); - assert_dv("-4297505365767445493397217468790201834500445721865584490206.4833018876772e-251", 0x97c918dbda46c035); - assert_dv("-2769941220215713.3656114593756752202597758990708934126457009789197379918e-252", 0x8ed2098083a3ab47); - assert_dv("83665682082666594318549387384108651957495373128979271258958370945.200492e-250", 0x198233aa14fceece); - assert_dv("302309202076196762164557210029165781545986673179.16980208580874983122589e-251", 0x15ae54965be8329d); - assert_dv("6967801947879737860.8915718988363887088043006283420885178585934184172191e-252", 0x0f86278edfa19bce); - assert_dv("-122401392953.46375536029949591691856839288446871935186966698907983879329e-250", 0x8e546783e62b0b2e); - assert_dv("-93021096470518964.450324121331012504574277642625805627190636296842738171e-251", 0x8f57a94908d98905); - assert_dv("-14312556666.679881690118941096110857241872231779360464724905841125316214e-252", 0x8db86e83ff346c07); - assert_dv("439938298717364095407601790036593895990867654987217682.07634781613470914e-250", 0x172a4f051c879e7f); - assert_dv("24468323976924527408558749276912182572942211413192705.131251813407232607e-251", 0x16b2bab2d4c01603); - assert_dv("89073.232781251680150616726545244984704519633166824505246449434623714045e-252", 0x0ca3edeb650cf6ec); - - assert_dv("626489130605178549050279883956995539671378178267525159430206689344267.188277827666e-300", 0x0fef1fd4ec9d5da8); - assert_dv("1641896005915820503012717856656983302358630989381773024640833402265.97872411354308e-301", 0x0f30b4a2a060905a); - assert_dv("955339528318750017059383464211683273320831534576660409122037.835718242850672659168e-302", 0x0db04ec9319c4467); - assert_dv("86565485417742241286182316761155710322880847993640292931033657019176928707402.0449e-300", 0x11a00564e48f46ee); - assert_dv("9944438567800637057284005182629377495213658679723517476093.95521943461592144747584e-302", 0x0d45ba751a73f8e5); - assert_dv("-37842184385853624394016950108544622893456333428669517703891.8152193136000832769135e-301", 0x8d99d6bcf113a0a8); - assert_dv("-23648726554887387668002732332991950159977696745809909031145816.4575990844176391038e-302", 0x8df93afc04bff403); - assert_dv("11748888671320196865287714662392072252362007385078295201091801641.2187296781618966e-301", 0x0ebe9a2d094b47cf); - - assert_dv( "1e-305", 0x009c16c5c5253575); - assert_dv("-1e-306", 0x8066789e3750f791); - assert_dv( "1e-307", 0x0031fa182c40c60d); - assert_dv("-1e-308", 0x800730d67819e8d2); - assert_dv( "1e-310", 0x000012688b70e62b); - assert_dv("-1e-311", 0x800001d74124e3d1); - assert_dv( "1e-312", 0x0000002f201d49fb); - assert_dv("-1e-314", 0x8000000078a42205); - assert_dv( "1e-315", 0x000000000c1069cd); - assert_dv("-1e-316", 0x800000000134d761); - assert_dv( "1e-318", 0x00000000000316a2); - assert_dv("-1e-319", 0x8000000000004f10); - assert_dv( "1e-320", 0x00000000000007e8); +def testDoubleVal(t: NumberParserTester) { + def DV = t.assert_dv; + + DV("0d", 0x0000000000000000); + DV("1d", 0x3FF0000000000000); + DV("2d", 0x4000000000000000); + DV("3d", 0x4008000000000000); + DV("4d", 0x4010000000000000); + + DV("-0d", 0x8000000000000000); + DV("-1d", 0xBFF0000000000000); + DV("-2d", 0xC000000000000000); + DV("-3d", 0xC008000000000000); + DV("-4d", 0xC010000000000000); + + DV("5d", 0x4014000000000000); + DV("6d", 0x4018000000000000); + DV("7d", 0x401C000000000000); + DV("8d", 0x4020000000000000); + DV("9d", 0x4022000000000000); + DV("10d", 0x4024000000000000); + DV("11d", 0x4026000000000000); + + DV("1e0", 0x3FF0000000000000); + DV("1e+0", 0x3FF0000000000000); + DV("1e-0", 0x3FF0000000000000); + DV("3e0", 0x4008000000000000); + DV("3e+0", 0x4008000000000000); + DV("3e-0", 0x4008000000000000); + + DV("1e1d", 0x4024000000000000); + DV("1e+1d", 0x4024000000000000); + DV("3e1D", 0x403E000000000000); + DV("3e+1D", 0x403E000000000000); + + DV("-5e5", 0xC11E848000000000); + DV("-3e6", 0xC146E36000000000); + DV("-9e9", 0xC200C388D0000000); + + DV("-5.0e5", 0xC11E848000000000); + DV("-5.00e5", 0xC11E848000000000); + DV("-5.000e5", 0xC11E848000000000); + DV("-5.0000e5", 0xC11E848000000000); + DV("-5.00000e5", 0xC11E848000000000); + + DV("2251799813685247d", 0x431FFFFFFFFFFFFC); + DV("2251799813685248d", 0x4320000000000000); + DV("2251799813685249d", 0x4320000000000002); + DV("2251799813685250d", 0x4320000000000004); + + DV("-2251799813685250d", 0xC320000000000004); + DV("-2251799813685251d", 0xC320000000000006); + + DV("4503599627370495d", 0x432FFFFFFFFFFFFE); + DV("4503599627370496d", 0x4330000000000000); + DV("4503599627370497d", 0x4330000000000001); + + DV("-4503599627370497d", 0xC330000000000001); + DV("-4503599627370498d", 0xC330000000000002); + + DV("9007199254740991d", 0x433FFFFFFFFFFFFF); + DV("9007199254740992d", 0x4340000000000000); + DV("9007199254740993d", 0x4340000000000000); + DV("9007199254740994d", 0x4340000000000001); + DV("9007199254740995d", 0x4340000000000002); + + DV("18014398509481982d", 0x434FFFFFFFFFFFFF); + DV("18014398509481983d", 0x4350000000000000); + DV("18014398509481984d", 0x4350000000000000); + DV("18014398509481985d", 0x4350000000000000); + DV("18014398509481986d", 0x4350000000000000); + + DV("2.251799813685247e15d", 0x431FFFFFFFFFFFFC); + DV("22.51799813685247e14d", 0x431FFFFFFFFFFFFC); + DV("225.1799813685247e13d", 0x431FFFFFFFFFFFFC); + DV("2251.799813685247e12d", 0x431FFFFFFFFFFFFC); + DV("22517.99813685247e11d", 0x431FFFFFFFFFFFFC); + DV("225179.9813685247e10d", 0x431FFFFFFFFFFFFC); + DV("2251799.813685247e9d", 0x431FFFFFFFFFFFFC); + DV("22517998.13685247e8d", 0x431FFFFFFFFFFFFC); + DV("225179981.3685247e7d", 0x431FFFFFFFFFFFFC); + DV("2251799813.685247e6d", 0x431FFFFFFFFFFFFC); + DV("22517998136.85247e5d", 0x431FFFFFFFFFFFFC); + DV("225179981368.5247e4d", 0x431FFFFFFFFFFFFC); + DV("2251799813685.247e3d", 0x431FFFFFFFFFFFFC); + DV("22517998136852.47e2d", 0x431FFFFFFFFFFFFC); + + DV("5e16", 0x4366345785D8A000); + DV("5e17", 0x439BC16D674EC800); + DV("5e18", 0x43D158E460913D00); + DV("5e19", 0x4405AF1D78B58C40); + DV("5e20", 0x443B1AE4D6E2EF50); + DV("5e21", 0x4470F0CF064DD592); + + DV("7e305", 0x7F6FE60E8164FD06); + DV("7e306", 0x7FA3EFC910DF1E24); + DV("7e307", 0x7FD8EBBB5516E5AD); + DV("7e308", 0x7FF0000000000000); + DV("7e309", 0x7FF0000000000000); + + DV("7.0e305", 0x7F6FE60E8164FD06); + DV("7.1e305", 0x7F702D5B787A87A2); + DV("-7.01e305", 0xFF6FF1B8F2F3653F); + DV("7.0e306", 0x7FA3EFC910DF1E24); + DV("7.0e307", 0x7FD8EBBB5516E5AD); + DV("7.0e308", 0x7FF0000000000000); + + DV("0.1e1", 0x3FF0000000000000); + DV("0.01e2", 0x3FF0000000000000); + DV("0.001e3", 0x3FF0000000000000); + DV("0.0001e4", 0x3FF0000000000000); + DV("0.000000000000000000000000000000000000000000000000000001e54", 0x3FF0000000000000); + + DV("0.18014398509481982e17d", 0x434FFFFFFFFFFFFF); + DV("0.0000018014398509481982e22d", 0x434FFFFFFFFFFFFF); + DV("-0.000000000018014398509481982e27d", 0xC34FFFFFFFFFFFFF); + + DV("0e-0d", 0x0000000000000000); + DV("0e-2", 0x0000000000000000); + DV("0e-32d", 0x0000000000000000); + DV("-0e-0d", 0x8000000000000000); + DV("-0e-32d", 0x8000000000000000); + + DV("0.0e-0d", 0x0000000000000000); + DV("0.00e-2", 0x0000000000000000); + DV("0.000e-32d", 0x0000000000000000); + DV("-0.0000e-0d", 0x8000000000000000); + DV("-0.00000e-32d", 0x8000000000000000); + + DV("0.1", 0x3fb999999999999a); + DV("-0.2", 0xbfc999999999999a); + DV("-0.3", 0xbfd3333333333333); + DV("0.5", 0x3fe0000000000000); + DV("-0.7", 0xbfe6666666666666); + DV("0.9", 0x3feccccccccccccd); + DV("1.1", 0x3ff199999999999a); + DV("-1.2", 0xbff3333333333333); + DV("1.3", 0x3ff4cccccccccccd); + DV("1.4", 0x3ff6666666666666); + DV("1.44", 0x3ff70a3d70a3d70a); + DV("2.33", 0x4002a3d70a3d70a4); + DV("4.11", 0x401070a3d70a3d71); + DV("5.55", 0x4016333333333333); + + DV("1.23456789e1", 0x4028b0fcd324d5a2); + DV("1.23456789e2", 0x405edd3c07ee0b0b); + DV("1.23456789e3", 0x40934a4584f4c6e7); + DV("1.23456789e10", 0x4206fee0e1a00000); + DV("1.23456789e-1", 0x3fbf9add3739635f); + DV("1.23456789e-2", 0x3f8948b0f8fab5e6); + DV("1.23456789e-5", 0x3ee9e409301b5a02); + DV("1.23456789e-9", 0x3e1535afdf51cc65); + DV("-1.23456789e-13", 0xbd415fffe53a685d); + DV("1.23456789e-33", 0x3919a416bc24b5d8); + DV("-1.23456789e-67", 0xb20aa08a1f46b961); + DV("5.669823e-60", 0x33a238dc1b6265f2); + DV("7.559823111222e-60", 0x33a84bdc97c884c5); + DV("-1.23456789e-103", 0xaa91b25e1ab9b3dd); + DV("1.23456789e-200", 0x166e3d71f615c1a8); + DV("1.23456789e-300", 0x01aa74fe1c132c0e); + + DV("181.618383758633790582e-10", 0x3e538049c22ae839); + DV("87.2832996973054334182e-11", 0x3e0dfd852e1201b7); + DV("75666880094465730285.3e-12", 0x41920a570060bba0); + DV("97914582937.6148465059e-13", 0x3f840d8b4936fefd); + DV("68671563.8508565834629e-14", 0x3ea70ad7a8b64b1d); + DV("28409978678876922140.9e-15", 0x40dbbe7ea2acba6b); + DV("-935239111910.502280784e-10", 0xc0576187c2cde46d); + DV("-1299655.47142223750168e-11", 0xbeeb4178e0f024f1); + DV("-4819573367496794.55021e-12", 0xc0b2d392c8365752); + DV("-655816518427468.551792e-13", 0xc0506539c8a69060); + DV("-392.680575416282618145e-14", 0xbd914530b318caf2); + DV("-74533874.7002032848397e-15", 0xbe7401edca53895d); + DV("9459803896626232.42941e-10", 0x412cde78c781dbff); + DV("88106218601.0303238072e-11", 0x3fec31a953550239); + DV("64714391942252.7564729e-12", 0x40502db898fb2019); + DV("53684.5675548620838520e-13", 0x3e370eae3d7f3b31); + DV("336.898219180856323863e-14", 0x3d8da246023fda0f); + DV("944929.708957285766454e-15", 0x3e103bd845731e9f); + DV("-70566543.0413272622408e-10", 0xbf7ce77037496e8d); + DV("-849283.932969460431721e-11", 0xbee1cf8ef3110f6b); + DV("-340016581683.942959995e-12", 0xbfd5c2d4e89b892d); + DV("-120653.674896922480273e-13", 0xbe49e901843ecddf); + DV("-267.379643644492056603e-14", 0xbd8784dab48bdecd); + DV("-82.7248210688390866278e-15", 0xbd3748f39a511eae); + DV("33049220.8276802354518e-10", 0x3f6b12ec885cb530); + DV("878783210.598898001485e-11", 0x3f81ff5adbfbd33a); + DV("6156442322083313.73074e-12", 0x40b80c713c052222); + DV("74193516915727671149.0e-13", 0x415c4d75ec42ba6c); + DV("19776517730996757664.6e-14", 0x410824296b217d00); + DV("7.93108569289931314599e-15", 0x3d01dbf5a9fdc6fc); + + DV("52752726596641413536348493.30370e-40", 0x3cf7c1f9acbc66e1); + DV("5606547191.364630149521729408396e-41", 0x397231bcb7c3d99f); + DV("183321504066877177116.5553948957e-42", 0x3b6bb3e83d548a6f); + DV("217573287432098988980122352.9349e-43", 0x3c7915a147bc74f0); + DV("9.811844312068794897773140099585e-44", 0x370181421f47942d); + DV("9476233371718431059094838037.641e-45", 0x3c65d9c7e643b34b); + DV("-359.2724344039193848598221842172e-40", 0xb82873689a71d668); + DV("-43588672818350475573678505952.86e-41", 0xbd5eac3cbae0187c); + DV("-172574948712499593743049315.1743e-42", 0xbca8dee44ea26980); + DV("-24.22433627673339965053032084376e-43", 0xb74b02d35b4927c7); + DV("-58363626.70718161468339162665295e-44", 0xb868d33c75c764f9); + DV("-538637872905.0462041870630977788e-45", 0xb9065fc7c32f78bf); + DV("77374373790467.61591928867200325e-40", 0x3a83282efe5ee499); + DV("256428100.6705829209489842387089e-41", 0x392aa1073887f4e3); + DV("287667153563840388221814.9538149e-42", 0x3c1539e0ff624981); + DV("7061551755.562964326161393668828e-43", 0x390d55213c85a313); + DV("8337908816.915929775460346629687e-44", 0x38dbb51bbe095c02); + DV("2561900570313278296922227.606489e-45", 0x3ba8324ba575d870); + DV("-677842.3251704117879138792739214e-40", 0xb8d68671dc75ca94); + DV("-9346849603125356031236231593.965e-41", 0xbd3a4f1d6cdcbadc); + DV("-560207394713.9608234160433559017e-42", 0xb9a6b986b47ad16c); + DV("-949859044657905112610860628.2289e-43", 0xbc9b60b901a1f026); + DV("-21667.66587764476260511749834445e-44", 0xb7b2e00d0b92bb1c); + DV("-52680480782763740.88984092015124e-45", 0xba10b1f2c78d2add); + DV("197142341156.0351654478288900107e-40", 0x39f8fda27e6e41dc); + DV("9019802903173354831277557498.807e-41", 0x3d396373f51ed006); + DV("50536213180372108209.26912408181e-42", 0x3b4e8c19a7c558a2); + DV("689347678622550189566.3380960156e-43", 0x3b54d591bf6dc0eb); + DV("9114341568048.812943402077656339e-44", 0x397d93e61378e539); + DV("27059543153867578.43760122136206e-45", 0x3a0126a972819425); + + DV("40406306512213302763134258.04011755764507261436810786026634788e-150", 0x261b5a1576db566a); + DV("770.2242232052013798311706780055732764525644530785033814980975e-151", 0x212f83fbb08603fc); + DV("1823630756912269.073168986837224562554585680653715099819306801e-152", 0x238b255c75bc77c5); + DV("-1271095456846779744.122225601260812580676565896049489104229575e-150", 0xa48cdf0d1b9b656e); + DV("-3073834102175485167602790344242519609096709008415176.627638789e-151", 0xab4583aeda112bd4); + DV("-76807041473499918.28219913405738422281004250357007396215643566e-152", 0xa3e1dd4b09f7aab2); + DV("473004324189367674577653220231042060278613271206.6035172291011e-150", 0x2ab0f356cc14f6d9); + DV("738128442461175122909232375959037.6587279938367440226464294523e-151", 0x2767d34d7afb08f5); + DV("6646.255694418556090987919878684243356765130789439879984439008e-152", 0x212b31da656590ea); + DV("-93739030.56901226422587564977689831587524824128343883601115493e-150", 0xa2724a132e420559); + DV("-5493869690922581902633545554553920427552769799448890.539976507e-151", 0xab5339f240d563dd); + DV("-55591683430622647660201338244717381889.07880801706568159681373e-152", 0xa835e77c2d7817a3); + DV("23221685933637335175798730660327806104229.38115631033034318048e-150", 0x292bec4a06ae3709); + DV("198859.6815487332390887724345038286727393742442636440016691442e-151", 0x21afc8d1530b0197); + DV("32122024942792611826720.34599725942530012718344270853097191745e-152", 0x250c801a87cea4ce); + + DV("55334153387763925503651114228820352318.400992904243313136623353042601433e-250", 0x13ddce1944fe3c78); + DV("853317531724299834.06934134094305577516602961382291952631169180845858123e-251", 0x0f8b21b84163ad54); + DV("5676916923311868526902859.5575084363007743978197221809956468259145827961e-252", 0x10c136c213e34bb8); + DV("-70496488926169100251287645.546104934749284973675351784247564018076851003e-250", 0x9164e0186e67ac52); + DV("-4297505365767445493397217468790201834500445721865584490206.4833018876772e-251", 0x97c918dbda46c035); + DV("-2769941220215713.3656114593756752202597758990708934126457009789197379918e-252", 0x8ed2098083a3ab47); + DV("83665682082666594318549387384108651957495373128979271258958370945.200492e-250", 0x198233aa14fceece); + DV("302309202076196762164557210029165781545986673179.16980208580874983122589e-251", 0x15ae54965be8329d); + DV("6967801947879737860.8915718988363887088043006283420885178585934184172191e-252", 0x0f86278edfa19bce); + DV("-122401392953.46375536029949591691856839288446871935186966698907983879329e-250", 0x8e546783e62b0b2e); + DV("-93021096470518964.450324121331012504574277642625805627190636296842738171e-251", 0x8f57a94908d98905); + DV("-14312556666.679881690118941096110857241872231779360464724905841125316214e-252", 0x8db86e83ff346c07); + DV("439938298717364095407601790036593895990867654987217682.07634781613470914e-250", 0x172a4f051c879e7f); + DV("24468323976924527408558749276912182572942211413192705.131251813407232607e-251", 0x16b2bab2d4c01603); + DV("89073.232781251680150616726545244984704519633166824505246449434623714045e-252", 0x0ca3edeb650cf6ec); + + DV("626489130605178549050279883956995539671378178267525159430206689344267.188277827666e-300", 0x0fef1fd4ec9d5da8); + DV("1641896005915820503012717856656983302358630989381773024640833402265.97872411354308e-301", 0x0f30b4a2a060905a); + DV("955339528318750017059383464211683273320831534576660409122037.835718242850672659168e-302", 0x0db04ec9319c4467); + DV("86565485417742241286182316761155710322880847993640292931033657019176928707402.0449e-300", 0x11a00564e48f46ee); + DV("9944438567800637057284005182629377495213658679723517476093.95521943461592144747584e-302", 0x0d45ba751a73f8e5); + DV("-37842184385853624394016950108544622893456333428669517703891.8152193136000832769135e-301", 0x8d99d6bcf113a0a8); + DV("-23648726554887387668002732332991950159977696745809909031145816.4575990844176391038e-302", 0x8df93afc04bff403); + DV("11748888671320196865287714662392072252362007385078295201091801641.2187296781618966e-301", 0x0ebe9a2d094b47cf); + + DV( "1e-305", 0x009c16c5c5253575); + DV("-1e-306", 0x8066789e3750f791); + DV( "1e-307", 0x0031fa182c40c60d); + DV("-1e-308", 0x800730d67819e8d2); + DV( "1e-310", 0x000012688b70e62b); + DV("-1e-311", 0x800001d74124e3d1); + DV( "1e-312", 0x0000002f201d49fb); + DV("-1e-314", 0x8000000078a42205); + DV( "1e-315", 0x000000000c1069cd); + DV("-1e-316", 0x800000000134d761); + DV( "1e-318", 0x00000000000316a2); + DV("-1e-319", 0x8000000000004f10); + DV( "1e-320", 0x00000000000007e8); // subnormal rounding - assert_dv("1.9999999999e-315", 0x000000001820d39b); - assert_dv("1.9999999999e-316", 0x000000000269aec3); - assert_dv("1.9999999999e-317", 0x00000000003dc4ad); - assert_dv("1.9999999999e-318", 0x0000000000062d45); - assert_dv("1.9999999999e-319", 0x0000000000009e20); - assert_dv("1.9999999999e-320", 0x0000000000000fd0); - assert_dv("1.9999999999e-321", 0x0000000000000195); - assert_dv("1.9999999999e-322", 0x0000000000000028); - assert_dv("1.9999999999e-323", 0x0000000000000004); - assert_dv("1.9999999999e-324", 0x0000000000000000); - assert_dv("1.9999999999e-325", 0x0000000000000000); - assert_dv("1.9999999999e-326", 0x0000000000000000); - - assert_dv("2.564E-320d", 0x0000000000001446); - assert_dv("1e-309", 0x0000b8157268fdaf); - assert_dv("1e-313", 0x00000004b6695433); - assert_dv("1e-317", 0x00000000001ee257); - assert_dv("-422406266499733910300745403518.761819278704724595823356575068949499439467425687244e-300", 0x87cc905726c3abd8); - assert_dv("-54042299570473738838741321824864482334385317603967.1369477788026330327559707766747e-301", 0x8bc3cf8b1d7c33f7); - assert_dv("-7565059281393020782220291572544429730556360928.21821474321245771328388190396147606e-302", 0x8ac22ca17db23131); - assert_dv("68290457691235513168.5642279371321049076040244718784461400695282923844829657845943e-301", 0x058fbbecdb58be41); - assert_dv("-8817413534132.89697570481945766633747700550227543340357019777620755501617715517930e-300", 0x84557b6bf2d63035); - assert_dv("71743801.8100733932315873628464212204901299587711750709434668465219690404318083338e-300", 0x0346e90749c24081); - assert_dv("7833586423668641728888268580170966033.10278838455627009562543835769266178262295650e-302", 0x08e4350d13cef890); - - assert_dv("-9.2233714870989619E18", 0xc3dfffffe0000000); - assert_dv("-9.2233720368547645E18", 0xc3dffffffffffff5); + DV("1.9999999999e-315", 0x000000001820d39b); + DV("1.9999999999e-316", 0x000000000269aec3); + DV("1.9999999999e-317", 0x00000000003dc4ad); + DV("1.9999999999e-318", 0x0000000000062d45); + DV("1.9999999999e-319", 0x0000000000009e20); + DV("1.9999999999e-320", 0x0000000000000fd0); + DV("1.9999999999e-321", 0x0000000000000195); + DV("1.9999999999e-322", 0x0000000000000028); + DV("1.9999999999e-323", 0x0000000000000004); + DV("1.9999999999e-324", 0x0000000000000000); + DV("1.9999999999e-325", 0x0000000000000000); + DV("1.9999999999e-326", 0x0000000000000000); + + DV("2.564E-320d", 0x0000000000001446); + DV("1e-309", 0x0000b8157268fdaf); + DV("1e-313", 0x00000004b6695433); + DV("1e-317", 0x00000000001ee257); + DV("-422406266499733910300745403518.761819278704724595823356575068949499439467425687244e-300", 0x87cc905726c3abd8); + DV("-54042299570473738838741321824864482334385317603967.1369477788026330327559707766747e-301", 0x8bc3cf8b1d7c33f7); + DV("-7565059281393020782220291572544429730556360928.21821474321245771328388190396147606e-302", 0x8ac22ca17db23131); + DV("68290457691235513168.5642279371321049076040244718784461400695282923844829657845943e-301", 0x058fbbecdb58be41); + DV("-8817413534132.89697570481945766633747700550227543340357019777620755501617715517930e-300", 0x84557b6bf2d63035); + DV("71743801.8100733932315873628464212204901299587711750709434668465219690404318083338e-300", 0x0346e90749c24081); + DV("7833586423668641728888268580170966033.10278838455627009562543835769266178262295650e-302", 0x08e4350d13cef890); + + DV("-9.2233714870989619E18", 0xc3dfffffe0000000); + DV("-9.2233720368547645E18", 0xc3dffffffffffff5); // Constants from exp and log algorithms - assert_dv("9.33263618503218878990e-302", 0x0170000000000000); - assert_dv("7.09782712893383973096e+2", 0x40862e42fefa39ef); - assert_dv("-7.45133219101941108420e+2", 0xc0874910d52d3051); - assert_dv("6.93147180369123816490e-1", 0x3fe62e42fee00000); - assert_dv("-6.93147180369123816490e-1", 0xbfe62e42fee00000); - assert_dv("1.90821492927058770002e-10", 0x3dea39ef35793c76); - assert_dv("-1.90821492927058770002e-10", 0xbdea39ef35793c76); - assert_dv("1.44269504088896338700e+0", 0x3ff71547652b82fe); - assert_dv("1.66666666666666019037e-1", 0x3fc555555555553e); - assert_dv("-2.77777777770155933842e-3", 0xbf66c16c16bebd93); - assert_dv("6.61375632143793436117e-5", 0x3f11566aaf25de2c); - assert_dv("-1.65339022054652515390e-6", 0xbebbbd41c5d26bf1); - assert_dv("4.13813679705723846039e-8", 0x3e66376972bea4d0); - assert_dv("6.93147180369123816490e-1", 0x3fe62e42fee00000); - assert_dv("1.90821492927058770002e-10", 0x3dea39ef35793c76); - assert_dv("1.80143985094819840000e+16", 0x4350000000000000); - assert_dv("6.666666666666735130e-1", 0x3fe5555555555593); - assert_dv("3.999999999940941908e-1", 0x3fd999999997fa04); - assert_dv("2.857142874366239149e-1", 0x3fd2492494229359); - assert_dv("2.222219843214978396e-1", 0x3fcc71c51d8e78af); - assert_dv("1.818357216161805012e-1", 0x3fc7466496cb03de); - assert_dv("1.531383769920937332e-1", 0x3fc39a09d078c69f); - assert_dv("1.479819860511658591e-1", 0x3fc2f112df3e5244); -} - -def testUnderscore() { - def test = test_implicit_int; - - test(0, "0_", "0x0_", "0b0_"); - test(0, "0_", "0x0_00", "0b0_000"); - test(1, "1_", "0x1_", "0b1_"); - test(-1, "-1_", "0xf_fffffff", "0b1_1111111111111111111111111111111"); - test(-2, "-2_", "0xff_fffffe", "0b11_111111111111111111111111111110"); - test(-3, "-3_", "0xfff_ffffd", "0b111_11111111111111111111111111101"); - test(-4, "-4_", "0xffff_fffc", "0b1111_1111111111111111111111111100"); - test(-5, "-5_", "0xfffff_ffb", "0b11111_111111111111111111111111011"); - test(-6, "-6_", "0xffffff_fa", "0b111111_11111111111111111111111010"); - - y_long("0x00_0000000123aF00", (0x00000000, 0x0123aF00)); - y_long("0x0000_0000_0123_aF00", (0x00000000, 0x0123aF00)); - - assert_dv("1.818_357216161805012e-1", 0x3fc7466496cb03de); - assert_dv("1.8183572161_61805012e-1", 0x3fc7466496cb03de); - assert_dv("1_.81835721616180___5012e-1", 0x3fc7466496cb03de); - assert_dv("1.818357216161805012___e-1", 0x3fc7466496cb03de); - assert_dv("-4224062_6649973_3910300745403518.76181927_87047245958233565_750689494994394_67425687244e-300", 0x87cc905726c3abd8); - - assert_fv("-758649_0734715.192621876706_151452080122799746379_8643716440736293925036482996157576791729202733568107336e-54f", 0x80001526); + DV("9.33263618503218878990e-302", 0x0170000000000000); + DV("7.09782712893383973096e+2", 0x40862e42fefa39ef); + DV("-7.45133219101941108420e+2", 0xc0874910d52d3051); + DV("6.93147180369123816490e-1", 0x3fe62e42fee00000); + DV("-6.93147180369123816490e-1", 0xbfe62e42fee00000); + DV("1.90821492927058770002e-10", 0x3dea39ef35793c76); + DV("-1.90821492927058770002e-10", 0xbdea39ef35793c76); + DV("1.44269504088896338700e+0", 0x3ff71547652b82fe); + DV("1.66666666666666019037e-1", 0x3fc555555555553e); + DV("-2.77777777770155933842e-3", 0xbf66c16c16bebd93); + DV("6.61375632143793436117e-5", 0x3f11566aaf25de2c); + DV("-1.65339022054652515390e-6", 0xbebbbd41c5d26bf1); + DV("4.13813679705723846039e-8", 0x3e66376972bea4d0); + DV("6.93147180369123816490e-1", 0x3fe62e42fee00000); + DV("1.90821492927058770002e-10", 0x3dea39ef35793c76); + DV("1.80143985094819840000e+16", 0x4350000000000000); + DV("6.666666666666735130e-1", 0x3fe5555555555593); + DV("3.999999999940941908e-1", 0x3fd999999997fa04); + DV("2.857142874366239149e-1", 0x3fd2492494229359); + DV("2.222219843214978396e-1", 0x3fcc71c51d8e78af); + DV("1.818357216161805012e-1", 0x3fc7466496cb03de); + DV("1.531383769920937332e-1", 0x3fc39a09d078c69f); + DV("1.479819860511658591e-1", 0x3fc2f112df3e5244); } -def assert_int_type(str: string, signed: bool, width: byte) { - var p = NumberParser.new(str); - p.accept_width = true; - if (!p.parse()) return TEST.error1("\"%s\" did not parse", str); - if (!IntType.?(p.vtype)) return TEST.error1("\"%s\" should be integral type", str); - var it = IntType.!(p.vtype); - if (it.signed != signed || it.width != width) return TEST.error3("\"%s\" expected type %q, got %q", str, Int.getType(signed, width).render, it.render); +def testUnderscore(t: NumberParserTester) { + def T = t.test_implicit_int; + + T(0, "0_", "0x0_", "0b0_"); + T(0, "0_", "0x0_00", "0b0_000"); + T(1, "1_", "0x1_", "0b1_"); + T(-1, "-1_", "0xf_fffffff", "0b1_1111111111111111111111111111111"); + T(-2, "-2_", "0xff_fffffe", "0b11_111111111111111111111111111110"); + T(-3, "-3_", "0xfff_ffffd", "0b111_11111111111111111111111111101"); + T(-4, "-4_", "0xffff_fffc", "0b1111_1111111111111111111111111100"); + T(-5, "-5_", "0xfffff_ffb", "0b11111_111111111111111111111111011"); + T(-6, "-6_", "0xffffff_fa", "0b111111_11111111111111111111111010"); + + t.y_long("0x00_0000000123aF00", (0x00000000, 0x0123aF00)); + t.y_long("0x0000_0000_0123_aF00", (0x00000000, 0x0123aF00)); + + def FV = t.assert_fv, DV = t.assert_dv; + DV("1.818_357216161805012e-1", 0x3fc7466496cb03de); + DV("1.8183572161_61805012e-1", 0x3fc7466496cb03de); + DV("1_.81835721616180___5012e-1", 0x3fc7466496cb03de); + DV("1.818357216161805012___e-1", 0x3fc7466496cb03de); + DV("-4224062_6649973_3910300745403518.76181927_87047245958233565_750689494994394_67425687244e-300", 0x87cc905726c3abd8); + + FV("-758649_0734715.192621876706_151452080122799746379_8643716440736293925036482996157576791729202733568107336e-54f", 0x80001526); } -def testWidth() { - def test = assert_int_type; - - test("1", true, 32); - test("2u", false, 32); - test("3L", true, 64); - test("4uL", false, 64); - - test("5u1", false, 1); - - l("0u66", 2); - l("0x0u66", 4); - - l("5U1", 2); - l("5ul1", 3); - l("5UL1", 3); - l("5uL1", 3); - l("3l22", 2); - l("4L23", 2); - l("-3l22", 3); - l("-4L23", 3); - - test("6u5", false, 5); - test("7u17", false, 17); - test("7u31", false, 31); - test("8u32", false, 32); - test("9u41", false, 41); - test("12u63", false, 63); - test("13u64", false, 64); - - test("0x5u1", false, 1); - test("0X6u5", false, 5); - test("0b01u17", false, 17); - test("0B10u17", false, 17); - - test("-5i1", true, 1); - test("-6i5", true, 5); - test("-7i17", true, 17); - test("-7i31", true, 31); - test("-8i32", true, 32); - test("-9i41", true, 41); - test("-12i63", true, 63); - test("-13i64", true, 64); - - test("5i1", true, 1); - test("6i5", true, 5); - test("7i17", true, 17); - test("7i31", true, 31); - test("8i32", true, 32); - test("9i41", true, 41); - test("12i63", true, 63); - test("13i64", true, 64); - - test("0x5i1", true, 1); - test("0X6i5", true, 5); - test("0b01i17", true, 17); - test("0B10i17", true, 17); +def testWidth(t: NumberParserTester) { + def L = t.assert_len; + def T = t.assert_int_type; + + T("1", true, 32); + T("2u", false, 32); + T("3L", true, 64); + T("4uL", false, 64); + + T("5u1", false, 1); + + L("0u66", 2); + L("0x0u66", 4); + + L("5U1", 2); + L("5ul1", 3); + L("5UL1", 3); + L("5uL1", 3); + L("3l22", 2); + L("4L23", 2); + L("-3l22", 3); + L("-4L23", 3); + + T("6u5", false, 5); + T("7u17", false, 17); + T("7u31", false, 31); + T("8u32", false, 32); + T("9u41", false, 41); + T("12u63", false, 63); + T("13u64", false, 64); + + T("0x5u1", false, 1); + T("0X6u5", false, 5); + T("0b01u17", false, 17); + T("0B10u17", false, 17); + + T("-5i1", true, 1); + T("-6i5", true, 5); + T("-7i17", true, 17); + T("-7i31", true, 31); + T("-8i32", true, 32); + T("-9i41", true, 41); + T("-12i63", true, 63); + T("-13i64", true, 64); + + T("5i1", true, 1); + T("6i5", true, 5); + T("7i17", true, 17); + T("7i31", true, 31); + T("8i32", true, 32); + T("9i41", true, 41); + T("12i63", true, 63); + T("13i64", true, 64); + + T("0x5i1", true, 1); + T("0X6i5", true, 5); + T("0b01i17", true, 17); + T("0B10i17", true, 17); }