diff --git a/bson/decimal128.py b/bson/decimal128.py index 0a2cf6ffa..8a0b3cf3b 100644 --- a/bson/decimal128.py +++ b/bson/decimal128.py @@ -12,7 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Tools for working with 128-bit IEEE 754-2008 decimal floating point numbers. +"""Tools for working with the BSON decimal128 type. + +.. versionadded:: 3.4 + +.. note:: The Decimal128 BSON type requires MongoDB 3.4+. """ import decimal @@ -52,9 +56,9 @@ _UNPACK_64 = struct.Struct(" _EXPONENT_MAX or exponent < _EXPONENT_MIN: - raise ValueError("Exponent is out of range for " - "Decimal128 encoding %d" % (exponent,)) - if bit_length > _MAX_BIT_LENGTH: - raise ValueError("Unscaled value is out of range for " - "Decimal128 encoding %d" % (significand,)) high = 0 low = 0 @@ -135,7 +164,51 @@ class Decimal128(object): - `value`: An instance of :class:`decimal.Decimal`, string, or tuple of (high bits, low bits) from Binary Integer Decimal (BID) format. - .. note:: To match the behavior of MongoDB's Decimal128 implementation + .. note:: :class:`~Decimal128` uses an instance of :class:`decimal.Context` + configured for IEEE-754 Decimal128 when validating parameters. + Signals like :class:`decimal.InvalidOperation`, :class:`decimal.Inexact`, + and :class:`decimal.Overflow` are trapped and raised as exceptions:: + + >>> Decimal128(".13.1") + Traceback (most recent call last): + File "", line 1, in + ... + decimal.InvalidOperation: [] + >>> + >>> Decimal128("1E-6177") + Traceback (most recent call last): + File "", line 1, in + ... + decimal.Inexact: [] + >>> + >>> Decimal128("1E6145") + Traceback (most recent call last): + File "", line 1, in + ... + decimal.Overflow: [, ] + + To ensure the result of a calculation can always be stored as BSON + Decimal128 use the context returned by + :func:`create_decimal128_context`:: + + >>> import decimal + >>> decimal128_ctx = create_decimal128_context() + >>> with decimal.localcontext(decimal128_ctx) as ctx: + ... Decimal128(ctx.create_decimal(".13.3")) + ... + Decimal128('NaN') + >>> + >>> with decimal.localcontext(decimal128_ctx) as ctx: + ... Decimal128(ctx.create_decimal("1E-6177")) + ... + Decimal128('0E-6176') + >>> + >>> with decimal.localcontext(DECIMAL128_CTX) as ctx: + ... Decimal128(ctx.create_decimal("1E6145")) + ... + Decimal128('Infinity') + + To match the behavior of MongoDB's Decimal128 implementation str(Decimal(value)) may not match str(Decimal128(value)) for NaN values:: >>> Decimal128(Decimal('NaN')) @@ -176,16 +249,7 @@ class Decimal128(object): _type_marker = 19 def __init__(self, value): - if isinstance(value, _string_type): - # Really? decimal.Decimal doesn't care... - if value.startswith(' ') or value.endswith(' '): - raise ValueError("leading or trailing whitespace") - try: - dec = decimal.Decimal(value) - except decimal.InvalidOperation as exc: - raise ValueError(str(exc)) - self.__high, self.__low = _decimal_to_128(dec) - elif isinstance(value, decimal.Decimal): + if isinstance(value, (_string_type, decimal.Decimal)): self.__high, self.__low = _decimal_to_128(value) elif isinstance(value, (list, tuple)): if len(value) != 2: @@ -234,7 +298,8 @@ class Decimal128(object): # Have to convert bytearray to bytes for python 2.6. digits = [int(digit) for digit in str(_from_bytes(bytes(arr), 'big'))] - return decimal.Decimal((sign, digits, exponent)) + with decimal.localcontext(_DEC128_CTX) as ctx: + return ctx.create_decimal((sign, digits, exponent)) @classmethod def from_bid(cls, value): diff --git a/test/decimal/decimal128.json b/test/decimal/decimal128-1.json similarity index 81% rename from test/decimal/decimal128.json rename to test/decimal/decimal128-1.json index a34c7e874..9811a0f1b 100644 --- a/test/decimal/decimal128.json +++ b/test/decimal/decimal128-1.json @@ -339,152 +339,19 @@ "string": "-Infinity", "to_extjson": false, "extjson": "{\"d\" : {\"$numberDecimal\" : \"-inF\"}}" + }, + { + "description": "Clamped", + "subject": "180000001364000a00000000000000000000000000fe5f00", + "string": "1E6112", + "match_string": "1.0E+6112" + }, + { + "description": "Exact rounding", + "subject": "18000000136400000000000a5bc138938d44c64d31cc3700", + "string": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "match_string": "1.000000000000000000000000000000000E+999" } - ], - "parseErrors": [ - { - "description": "Too many significand digits", - "subject": "100000000000000000000000000000000000000000000000000000000001" - }, - { - "description": "Too many significand digits", - "subject": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - }, - { - "description": "Too many significand digits", - "subject": ".100000000000000000000000000000000000000000000000000000000000" - }, - { - "description": "Incomplete Exponent", - "subject": "1e" - }, - { - "description": "Exponent at the beginning", - "subject": "E01" - }, - { - "description": "Exponent too large", - "subject": "1E6112" - }, - { - "description": "Exponent too small", - "subject": "1E-6177" - }, - { - "description": "Just a decimal place", - "subject": "." - }, - { - "description": "2 decimal places", - "subject": "..3" - }, - { - "description": "2 decimal places", - "subject": ".13.3" - }, - { - "description": "2 decimal places", - "subject": "1..3" - }, - { - "description": "2 decimal places", - "subject": "1.3.4" - }, - { - "description": "2 decimal places", - "subject": "1.34." - }, - { - "description": "Decimal with no digits", - "subject": ".e" - }, - { - "description": "2 signs", - "subject": "+-32.4" - }, - { - "description": "2 signs", - "subject": "-+32.4" - }, - { - "description": "2 negative signs", - "subject": "--32.4" - }, - { - "description": "2 negative signs", - "subject": "-32.-4" - }, - { - "description": "End in negative sign", - "subject": "32.0-" - }, - { - "description": "2 negative signs", - "subject": "32.4E--21" - }, - { - "description": "2 negative signs", - "subject": "32.4E-2-1" - }, - { - "description": "2 signs", - "subject": "32.4E+-21" - }, - { - "description": "Empty string", - "subject": "" - }, - { - "description": "leading white space positive number", - "subject": " 1" - }, - { - "description": "leading white space negative number", - "subject": " -1" - }, - { - "description": "trailing white space", - "subject": "1 " - }, - { - "description": "Invalid", - "subject": "E" - }, - { - "description": "Invalid", - "subject": "invalid" - }, - { - "description": "Invalid", - "subject": "i" - }, - { - "description": "Invalid", - "subject": "in" - }, - { - "description": "Invalid", - "subject": "-in" - }, - { - "description": "Invalid", - "subject": "Na" - }, - { - "description": "Invalid", - "subject": "-Na" - }, - { - "description": "Invalid", - "subject": "1.23abc" - }, - { - "description": "Invalid", - "subject": "1.23abcE+02" - }, - { - "description": "Invalid", - "subject": "1.23E+0aabs2" - } + ] } diff --git a/test/decimal/decimal128-2.json b/test/decimal/decimal128-2.json new file mode 100644 index 000000000..7a52dccc6 --- /dev/null +++ b/test/decimal/decimal128-2.json @@ -0,0 +1,793 @@ +{ + "description": "Decimal128", + "bson_type": "0x13", + "test_key": "d", + "valid": [ + { + "description": "[decq021] Normality", + "subject": "18000000136400F2AF967ED05C82DE3297FF6FDE3C40B000", + "string": "-1234567890123456789012345678901234" + }, + { + "description": "[decq823] values around [u]int32 edges (zeros done earlier)", + "subject": "18000000136400010000800000000000000000000040B000", + "string": "-2147483649" + }, + { + "description": "[decq822] values around [u]int32 edges (zeros done earlier)", + "subject": "18000000136400000000800000000000000000000040B000", + "string": "-2147483648" + }, + { + "description": "[decq821] values around [u]int32 edges (zeros done earlier)", + "subject": "18000000136400FFFFFF7F0000000000000000000040B000", + "string": "-2147483647" + }, + { + "description": "[decq820] values around [u]int32 edges (zeros done earlier)", + "subject": "18000000136400FEFFFF7F0000000000000000000040B000", + "string": "-2147483646" + }, + { + "description": "[decq152] fold-downs (more below)", + "subject": "18000000136400393000000000000000000000000040B000", + "string": "-12345" + }, + { + "description": "[decq154] fold-downs (more below)", + "subject": "18000000136400D20400000000000000000000000040B000", + "string": "-1234" + }, + { + "description": "[decq006] derivative canonical plain strings", + "subject": "18000000136400EE0200000000000000000000000040B000", + "string": "-750" + }, + { + "description": "[decq164] fold-downs (more below)", + "subject": "1800000013640039300000000000000000000000003CB000", + "string": "-123.45" + }, + { + "description": "[decq156] fold-downs (more below)", + "subject": "180000001364007B0000000000000000000000000040B000", + "string": "-123" + }, + { + "description": "[decq008] derivative canonical plain strings", + "subject": "18000000136400EE020000000000000000000000003EB000", + "string": "-75.0" + }, + { + "description": "[decq158] fold-downs (more below)", + "subject": "180000001364000C0000000000000000000000000040B000", + "string": "-12" + }, + { + "description": "[decq122] Nmax and similar", + "subject": "18000000136400FFFFFFFF638E8D37C087ADBE09EDFFDF00", + "string": "-9.999999999999999999999999999999999E+6144" + }, + { + "description": "[decq002] (mostly derived from the Strawman 4 document and examples)", + "subject": "18000000136400EE020000000000000000000000003CB000", + "string": "-7.50" + }, + { + "description": "[decq004] derivative canonical plain strings", + "subject": "18000000136400EE0200000000000000000000000042B000", + "string": "-7.50E+3" + }, + { + "description": "[decq018] derivative canonical plain strings", + "subject": "18000000136400EE020000000000000000000000002EB000", + "string": "-7.50E-7" + }, + { + "description": "[decq125] Nmax and similar", + "subject": "18000000136400F2AF967ED05C82DE3297FF6FDE3CFEDF00", + "string": "-1.234567890123456789012345678901234E+6144" + }, + { + "description": "[decq131] fold-downs (more below)", + "subject": "18000000136400000000807F1BCF85B27059C8A43CFEDF00", + "string": "-1.230000000000000000000000000000000E+6144" + }, + { + "description": "[decq162] fold-downs (more below)", + "subject": "180000001364007B000000000000000000000000003CB000", + "string": "-1.23" + }, + { + "description": "[decq176] Nmin and below", + "subject": "18000000136400010000000A5BC138938D44C64D31008000", + "string": "-1.000000000000000000000000000000001E-6143" + }, + { + "description": "[decq174] Nmin and below", + "subject": "18000000136400000000000A5BC138938D44C64D31008000", + "string": "-1.000000000000000000000000000000000E-6143" + }, + { + "description": "[decq133] fold-downs (more below)", + "subject": "18000000136400000000000A5BC138938D44C64D31FEDF00", + "string": "-1.000000000000000000000000000000000E+6144" + }, + { + "description": "[decq160] fold-downs (more below)", + "subject": "18000000136400010000000000000000000000000040B000", + "string": "-1" + }, + { + "description": "[decq172] Nmin and below", + "subject": "180000001364000100000000000000000000000000428000", + "string": "-1E-6143" + }, + { + "description": "[decq010] derivative canonical plain strings", + "subject": "18000000136400EE020000000000000000000000003AB000", + "string": "-0.750" + }, + { + "description": "[decq012] derivative canonical plain strings", + "subject": "18000000136400EE0200000000000000000000000038B000", + "string": "-0.0750" + }, + { + "description": "[decq014] derivative canonical plain strings", + "subject": "18000000136400EE0200000000000000000000000034B000", + "string": "-0.000750" + }, + { + "description": "[decq016] derivative canonical plain strings", + "subject": "18000000136400EE0200000000000000000000000030B000", + "string": "-0.00000750" + }, + { + "description": "[decq404] zeros", + "subject": "180000001364000000000000000000000000000000000000", + "string": "0E-6176" + }, + { + "description": "[decq424] negative zeros", + "subject": "180000001364000000000000000000000000000000008000", + "string": "-0E-6176" + }, + { + "description": "[decq407] zeros", + "subject": "1800000013640000000000000000000000000000003C3000", + "string": "0.00" + }, + { + "description": "[decq427] negative zeros", + "subject": "1800000013640000000000000000000000000000003CB000", + "string": "-0.00" + }, + { + "description": "[decq409] zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "0" + }, + { + "description": "[decq428] negative zeros", + "subject": "18000000136400000000000000000000000000000040B000", + "string": "-0" + }, + { + "description": "[decq700] Selected DPD codes", + "subject": "180000001364000000000000000000000000000000403000", + "string": "0" + }, + { + "description": "[decq406] zeros", + "subject": "1800000013640000000000000000000000000000003C3000", + "string": "0.00" + }, + { + "description": "[decq426] negative zeros", + "subject": "1800000013640000000000000000000000000000003CB000", + "string": "-0.00" + }, + { + "description": "[decq410] zeros", + "subject": "180000001364000000000000000000000000000000463000", + "string": "0E+3" + }, + { + "description": "[decq431] negative zeros", + "subject": "18000000136400000000000000000000000000000046B000", + "string": "-0E+3" + }, + { + "description": "[decq419] clamped zeros...", + "subject": "180000001364000000000000000000000000000000FE5F00", + "string": "0E+6111" + }, + { + "description": "[decq432] negative zeros", + "subject": "180000001364000000000000000000000000000000FEDF00", + "string": "-0E+6111" + }, + { + "description": "[decq405] zeros", + "subject": "180000001364000000000000000000000000000000000000", + "string": "0E-6176" + }, + { + "description": "[decq425] negative zeros", + "subject": "180000001364000000000000000000000000000000008000", + "string": "-0E-6176" + }, + { + "description": "[decq508] Specials", + "subject": "180000001364000000000000000000000000000000007800", + "string": "Infinity" + }, + { + "description": "[decq528] Specials", + "subject": "18000000136400000000000000000000000000000000F800", + "string": "-Infinity" + }, + { + "description": "[decq541] Specials", + "subject": "180000001364000000000000000000000000000000007C00", + "string": "NaN" + }, + { + "description": "[decq074] Nmin and below", + "subject": "18000000136400000000000A5BC138938D44C64D31000000", + "string": "1.000000000000000000000000000000000E-6143" + }, + { + "description": "[decq602] fold-down full sequence", + "subject": "18000000136400000000000A5BC138938D44C64D31FE5F00", + "string": "1.000000000000000000000000000000000E+6144" + }, + { + "description": "[decq604] fold-down full sequence", + "subject": "180000001364000000000081EFAC855B416D2DEE04FE5F00", + "string": "1.00000000000000000000000000000000E+6143" + }, + { + "description": "[decq606] fold-down full sequence", + "subject": "1800000013640000000080264B91C02220BE377E00FE5F00", + "string": "1.0000000000000000000000000000000E+6142" + }, + { + "description": "[decq608] fold-down full sequence", + "subject": "1800000013640000000040EAED7446D09C2C9F0C00FE5F00", + "string": "1.000000000000000000000000000000E+6141" + }, + { + "description": "[decq610] fold-down full sequence", + "subject": "18000000136400000000A0CA17726DAE0F1E430100FE5F00", + "string": "1.00000000000000000000000000000E+6140" + }, + { + "description": "[decq612] fold-down full sequence", + "subject": "18000000136400000000106102253E5ECE4F200000FE5F00", + "string": "1.0000000000000000000000000000E+6139" + }, + { + "description": "[decq614] fold-down full sequence", + "subject": "18000000136400000000E83C80D09F3C2E3B030000FE5F00", + "string": "1.000000000000000000000000000E+6138" + }, + { + "description": "[decq616] fold-down full sequence", + "subject": "18000000136400000000E4D20CC8DCD2B752000000FE5F00", + "string": "1.00000000000000000000000000E+6137" + }, + { + "description": "[decq618] fold-down full sequence", + "subject": "180000001364000000004A48011416954508000000FE5F00", + "string": "1.0000000000000000000000000E+6136" + }, + { + "description": "[decq620] fold-down full sequence", + "subject": "18000000136400000000A1EDCCCE1BC2D300000000FE5F00", + "string": "1.000000000000000000000000E+6135" + }, + { + "description": "[decq622] fold-down full sequence", + "subject": "18000000136400000080F64AE1C7022D1500000000FE5F00", + "string": "1.00000000000000000000000E+6134" + }, + { + "description": "[decq624] fold-down full sequence", + "subject": "18000000136400000040B2BAC9E0191E0200000000FE5F00", + "string": "1.0000000000000000000000E+6133" + }, + { + "description": "[decq626] fold-down full sequence", + "subject": "180000001364000000A0DEC5ADC935360000000000FE5F00", + "string": "1.000000000000000000000E+6132" + }, + { + "description": "[decq628] fold-down full sequence", + "subject": "18000000136400000010632D5EC76B050000000000FE5F00", + "string": "1.00000000000000000000E+6131" + }, + { + "description": "[decq630] fold-down full sequence", + "subject": "180000001364000000E8890423C78A000000000000FE5F00", + "string": "1.0000000000000000000E+6130" + }, + { + "description": "[decq632] fold-down full sequence", + "subject": "18000000136400000064A7B3B6E00D000000000000FE5F00", + "string": "1.000000000000000000E+6129" + }, + { + "description": "[decq634] fold-down full sequence", + "subject": "1800000013640000008A5D78456301000000000000FE5F00", + "string": "1.00000000000000000E+6128" + }, + { + "description": "[decq636] fold-down full sequence", + "subject": "180000001364000000C16FF2862300000000000000FE5F00", + "string": "1.0000000000000000E+6127" + }, + { + "description": "[decq638] fold-down full sequence", + "subject": "180000001364000080C6A47E8D0300000000000000FE5F00", + "string": "1.000000000000000E+6126" + }, + { + "description": "[decq640] fold-down full sequence", + "subject": "1800000013640000407A10F35A0000000000000000FE5F00", + "string": "1.00000000000000E+6125" + }, + { + "description": "[decq642] fold-down full sequence", + "subject": "1800000013640000A0724E18090000000000000000FE5F00", + "string": "1.0000000000000E+6124" + }, + { + "description": "[decq644] fold-down full sequence", + "subject": "180000001364000010A5D4E8000000000000000000FE5F00", + "string": "1.000000000000E+6123" + }, + { + "description": "[decq646] fold-down full sequence", + "subject": "1800000013640000E8764817000000000000000000FE5F00", + "string": "1.00000000000E+6122" + }, + { + "description": "[decq648] fold-down full sequence", + "subject": "1800000013640000E40B5402000000000000000000FE5F00", + "string": "1.0000000000E+6121" + }, + { + "description": "[decq650] fold-down full sequence", + "subject": "1800000013640000CA9A3B00000000000000000000FE5F00", + "string": "1.000000000E+6120" + }, + { + "description": "[decq652] fold-down full sequence", + "subject": "1800000013640000E1F50500000000000000000000FE5F00", + "string": "1.00000000E+6119" + }, + { + "description": "[decq654] fold-down full sequence", + "subject": "180000001364008096980000000000000000000000FE5F00", + "string": "1.0000000E+6118" + }, + { + "description": "[decq656] fold-down full sequence", + "subject": "1800000013640040420F0000000000000000000000FE5F00", + "string": "1.000000E+6117" + }, + { + "description": "[decq658] fold-down full sequence", + "subject": "18000000136400A086010000000000000000000000FE5F00", + "string": "1.00000E+6116" + }, + { + "description": "[decq660] fold-down full sequence", + "subject": "180000001364001027000000000000000000000000FE5F00", + "string": "1.0000E+6115" + }, + { + "description": "[decq662] fold-down full sequence", + "subject": "18000000136400E803000000000000000000000000FE5F00", + "string": "1.000E+6114" + }, + { + "description": "[decq664] fold-down full sequence", + "subject": "180000001364006400000000000000000000000000FE5F00", + "string": "1.00E+6113" + }, + { + "description": "[decq666] fold-down full sequence", + "subject": "180000001364000A00000000000000000000000000FE5F00", + "string": "1.0E+6112" + }, + { + "description": "[decq060] fold-downs (more below)", + "subject": "180000001364000100000000000000000000000000403000", + "string": "1" + }, + { + "description": "[decq670] fold-down full sequence", + "subject": "180000001364000100000000000000000000000000FC5F00", + "string": "1E+6110" + }, + { + "description": "[decq668] fold-down full sequence", + "subject": "180000001364000100000000000000000000000000FE5F00", + "string": "1E+6111" + }, + { + "description": "[decq072] Nmin and below", + "subject": "180000001364000100000000000000000000000000420000", + "string": "1E-6143" + }, + { + "description": "[decq076] Nmin and below", + "subject": "18000000136400010000000A5BC138938D44C64D31000000", + "string": "1.000000000000000000000000000000001E-6143" + }, + { + "description": "[decq036] fold-downs (more below)", + "subject": "18000000136400000000807F1BCF85B27059C8A43CFE5F00", + "string": "1.230000000000000000000000000000000E+6144" + }, + { + "description": "[decq062] fold-downs (more below)", + "subject": "180000001364007B000000000000000000000000003C3000", + "string": "1.23" + }, + { + "description": "[decq034] Nmax and similar", + "subject": "18000000136400F2AF967ED05C82DE3297FF6FDE3CFE5F00", + "string": "1.234567890123456789012345678901234E+6144" + }, + { + "description": "[decq441] exponent lengths", + "subject": "180000001364000700000000000000000000000000403000", + "string": "7" + }, + { + "description": "[decq449] exponent lengths", + "subject": "1800000013640007000000000000000000000000001E5F00", + "string": "7E+5999" + }, + { + "description": "[decq447] exponent lengths", + "subject": "1800000013640007000000000000000000000000000E3800", + "string": "7E+999" + }, + { + "description": "[decq445] exponent lengths", + "subject": "180000001364000700000000000000000000000000063100", + "string": "7E+99" + }, + { + "description": "[decq443] exponent lengths", + "subject": "180000001364000700000000000000000000000000523000", + "string": "7E+9" + }, + { + "description": "[decq842] VG testcase", + "subject": "180000001364000000FED83F4E7C9FE4E269E38A5BCD1700", + "string": "7.049000000000010795488000000000000E-3097" + }, + { + "description": "[decq841] VG testcase", + "subject": "180000001364000000203B9DB5056F000000000000002400", + "string": "8.000000000000000000E-1550" + }, + { + "description": "[decq840] VG testcase", + "subject": "180000001364003C17258419D710C42F0000000000002400", + "string": "8.81125000000001349436E-1548" + }, + { + "description": "[decq701] Selected DPD codes", + "subject": "180000001364000900000000000000000000000000403000", + "string": "9" + }, + { + "description": "[decq032] Nmax and similar", + "subject": "18000000136400FFFFFFFF638E8D37C087ADBE09EDFF5F00", + "string": "9.999999999999999999999999999999999E+6144" + }, + { + "description": "[decq702] Selected DPD codes", + "subject": "180000001364000A00000000000000000000000000403000", + "string": "10" + }, + { + "description": "[decq057] fold-downs (more below)", + "subject": "180000001364000C00000000000000000000000000403000", + "string": "12" + }, + { + "description": "[decq703] Selected DPD codes", + "subject": "180000001364001300000000000000000000000000403000", + "string": "19" + }, + { + "description": "[decq704] Selected DPD codes", + "subject": "180000001364001400000000000000000000000000403000", + "string": "20" + }, + { + "description": "[decq705] Selected DPD codes", + "subject": "180000001364001D00000000000000000000000000403000", + "string": "29" + }, + { + "description": "[decq706] Selected DPD codes", + "subject": "180000001364001E00000000000000000000000000403000", + "string": "30" + }, + { + "description": "[decq707] Selected DPD codes", + "subject": "180000001364002700000000000000000000000000403000", + "string": "39" + }, + { + "description": "[decq708] Selected DPD codes", + "subject": "180000001364002800000000000000000000000000403000", + "string": "40" + }, + { + "description": "[decq709] Selected DPD codes", + "subject": "180000001364003100000000000000000000000000403000", + "string": "49" + }, + { + "description": "[decq710] Selected DPD codes", + "subject": "180000001364003200000000000000000000000000403000", + "string": "50" + }, + { + "description": "[decq711] Selected DPD codes", + "subject": "180000001364003B00000000000000000000000000403000", + "string": "59" + }, + { + "description": "[decq712] Selected DPD codes", + "subject": "180000001364003C00000000000000000000000000403000", + "string": "60" + }, + { + "description": "[decq713] Selected DPD codes", + "subject": "180000001364004500000000000000000000000000403000", + "string": "69" + }, + { + "description": "[decq714] Selected DPD codes", + "subject": "180000001364004600000000000000000000000000403000", + "string": "70" + }, + { + "description": "[decq715] Selected DPD codes", + "subject": "180000001364004700000000000000000000000000403000", + "string": "71" + }, + { + "description": "[decq716] Selected DPD codes", + "subject": "180000001364004800000000000000000000000000403000", + "string": "72" + }, + { + "description": "[decq717] Selected DPD codes", + "subject": "180000001364004900000000000000000000000000403000", + "string": "73" + }, + { + "description": "[decq718] Selected DPD codes", + "subject": "180000001364004A00000000000000000000000000403000", + "string": "74" + }, + { + "description": "[decq719] Selected DPD codes", + "subject": "180000001364004B00000000000000000000000000403000", + "string": "75" + }, + { + "description": "[decq720] Selected DPD codes", + "subject": "180000001364004C00000000000000000000000000403000", + "string": "76" + }, + { + "description": "[decq721] Selected DPD codes", + "subject": "180000001364004D00000000000000000000000000403000", + "string": "77" + }, + { + "description": "[decq722] Selected DPD codes", + "subject": "180000001364004E00000000000000000000000000403000", + "string": "78" + }, + { + "description": "[decq723] Selected DPD codes", + "subject": "180000001364004F00000000000000000000000000403000", + "string": "79" + }, + { + "description": "[decq056] fold-downs (more below)", + "subject": "180000001364007B00000000000000000000000000403000", + "string": "123" + }, + { + "description": "[decq064] fold-downs (more below)", + "subject": "1800000013640039300000000000000000000000003C3000", + "string": "123.45" + }, + { + "description": "[decq732] Selected DPD codes", + "subject": "180000001364000802000000000000000000000000403000", + "string": "520" + }, + { + "description": "[decq733] Selected DPD codes", + "subject": "180000001364000902000000000000000000000000403000", + "string": "521" + }, + { + "description": "[decq740] DPD: one of each of the huffman groups", + "subject": "180000001364000903000000000000000000000000403000", + "string": "777" + }, + { + "description": "[decq741] DPD: one of each of the huffman groups", + "subject": "180000001364000A03000000000000000000000000403000", + "string": "778" + }, + { + "description": "[decq742] DPD: one of each of the huffman groups", + "subject": "180000001364001303000000000000000000000000403000", + "string": "787" + }, + { + "description": "[decq746] DPD: one of each of the huffman groups", + "subject": "180000001364001F03000000000000000000000000403000", + "string": "799" + }, + { + "description": "[decq743] DPD: one of each of the huffman groups", + "subject": "180000001364006D03000000000000000000000000403000", + "string": "877" + }, + { + "description": "[decq753] DPD all-highs cases (includes the 24 redundant codes)", + "subject": "180000001364007803000000000000000000000000403000", + "string": "888" + }, + { + "description": "[decq754] DPD all-highs cases (includes the 24 redundant codes)", + "subject": "180000001364007903000000000000000000000000403000", + "string": "889" + }, + { + "description": "[decq760] DPD all-highs cases (includes the 24 redundant codes)", + "subject": "180000001364008203000000000000000000000000403000", + "string": "898" + }, + { + "description": "[decq764] DPD all-highs cases (includes the 24 redundant codes)", + "subject": "180000001364008303000000000000000000000000403000", + "string": "899" + }, + { + "description": "[decq745] DPD: one of each of the huffman groups", + "subject": "18000000136400D303000000000000000000000000403000", + "string": "979" + }, + { + "description": "[decq770] DPD all-highs cases (includes the 24 redundant codes)", + "subject": "18000000136400DC03000000000000000000000000403000", + "string": "988" + }, + { + "description": "[decq774] DPD all-highs cases (includes the 24 redundant codes)", + "subject": "18000000136400DD03000000000000000000000000403000", + "string": "989" + }, + { + "description": "[decq730] Selected DPD codes", + "subject": "18000000136400E203000000000000000000000000403000", + "string": "994" + }, + { + "description": "[decq731] Selected DPD codes", + "subject": "18000000136400E303000000000000000000000000403000", + "string": "995" + }, + { + "description": "[decq744] DPD: one of each of the huffman groups", + "subject": "18000000136400E503000000000000000000000000403000", + "string": "997" + }, + { + "description": "[decq780] DPD all-highs cases (includes the 24 redundant codes)", + "subject": "18000000136400E603000000000000000000000000403000", + "string": "998" + }, + { + "description": "[decq787] DPD all-highs cases (includes the 24 redundant codes)", + "subject": "18000000136400E703000000000000000000000000403000", + "string": "999" + }, + { + "description": "[decq053] fold-downs (more below)", + "subject": "18000000136400D204000000000000000000000000403000", + "string": "1234" + }, + { + "description": "[decq052] fold-downs (more below)", + "subject": "180000001364003930000000000000000000000000403000", + "string": "12345" + }, + { + "description": "[decq792] Miscellaneous (testers' queries, etc.)", + "subject": "180000001364003075000000000000000000000000403000", + "string": "30000" + }, + { + "description": "[decq793] Miscellaneous (testers' queries, etc.)", + "subject": "1800000013640090940D0000000000000000000000403000", + "string": "890000" + }, + { + "description": "[decq824] values around [u]int32 edges (zeros done earlier)", + "subject": "18000000136400FEFFFF7F00000000000000000000403000", + "string": "2147483646" + }, + { + "description": "[decq825] values around [u]int32 edges (zeros done earlier)", + "subject": "18000000136400FFFFFF7F00000000000000000000403000", + "string": "2147483647" + }, + { + "description": "[decq826] values around [u]int32 edges (zeros done earlier)", + "subject": "180000001364000000008000000000000000000000403000", + "string": "2147483648" + }, + { + "description": "[decq827] values around [u]int32 edges (zeros done earlier)", + "subject": "180000001364000100008000000000000000000000403000", + "string": "2147483649" + }, + { + "description": "[decq828] values around [u]int32 edges (zeros done earlier)", + "subject": "18000000136400FEFFFFFF00000000000000000000403000", + "string": "4294967294" + }, + { + "description": "[decq829] values around [u]int32 edges (zeros done earlier)", + "subject": "18000000136400FFFFFFFF00000000000000000000403000", + "string": "4294967295" + }, + { + "description": "[decq830] values around [u]int32 edges (zeros done earlier)", + "subject": "180000001364000000000001000000000000000000403000", + "string": "4294967296" + }, + { + "description": "[decq831] values around [u]int32 edges (zeros done earlier)", + "subject": "180000001364000100000001000000000000000000403000", + "string": "4294967297" + }, + { + "description": "[decq022] Normality", + "subject": "18000000136400C7711CC7B548F377DC80A131C836403000", + "string": "1111111111111111111111111111111111" + }, + { + "description": "[decq020] Normality", + "subject": "18000000136400F2AF967ED05C82DE3297FF6FDE3C403000", + "string": "1234567890123456789012345678901234" + }, + { + "description": "[decq550] Specials", + "subject": "18000000136400FFFFFFFF638E8D37C087ADBE09ED413000", + "string": "9999999999999999999999999999999999" + } + ] +} + diff --git a/test/decimal/decimal128-3.json b/test/decimal/decimal128-3.json new file mode 100644 index 000000000..c13720344 --- /dev/null +++ b/test/decimal/decimal128-3.json @@ -0,0 +1,1771 @@ +{ + "description": "Decimal128", + "bson_type": "0x13", + "test_key": "d", + "valid": [ + { + "description": "[basx066] strings without E cannot generate E in result", + "subject": "18000000136400185C0ACE0000000000000000000038B000", + "string": "-00345678.5432", + "match_string": "-345678.5432" + }, + { + "description": "[basx065] strings without E cannot generate E in result", + "subject": "18000000136400185C0ACE0000000000000000000038B000", + "string": "-0345678.5432", + "match_string": "-345678.5432" + }, + { + "description": "[basx064] strings without E cannot generate E in result", + "subject": "18000000136400185C0ACE0000000000000000000038B000", + "string": "-345678.5432" + }, + { + "description": "[basx041] strings without E cannot generate E in result", + "subject": "180000001364004C0000000000000000000000000040B000", + "string": "-76" + }, + { + "description": "[basx027] conform to rules and exponent will be in permitted range).", + "subject": "180000001364000F270000000000000000000000003AB000", + "string": "-9.999" + }, + { + "description": "[basx026] conform to rules and exponent will be in permitted range).", + "subject": "180000001364009F230000000000000000000000003AB000", + "string": "-9.119" + }, + { + "description": "[basx025] conform to rules and exponent will be in permitted range).", + "subject": "180000001364008F030000000000000000000000003CB000", + "string": "-9.11" + }, + { + "description": "[basx024] conform to rules and exponent will be in permitted range).", + "subject": "180000001364005B000000000000000000000000003EB000", + "string": "-9.1" + }, + { + "description": "[dqbsr531] negatives (Rounded)", + "subject": "1800000013640099761CC7B548F377DC80A131C836FEAF00", + "string": "-1.1111111111111111111111111111123450", + "match_string": "-1.111111111111111111111111111112345" + }, + { + "description": "[basx022] conform to rules and exponent will be in permitted range).", + "subject": "180000001364000A000000000000000000000000003EB000", + "string": "-1.0" + }, + { + "description": "[basx021] conform to rules and exponent will be in permitted range).", + "subject": "18000000136400010000000000000000000000000040B000", + "string": "-1" + }, + { + "description": "[basx601] Zeros", + "subject": "1800000013640000000000000000000000000000002E3000", + "string": "0.000000000", + "match_string": "0E-9" + }, + { + "description": "[basx622] Zeros", + "subject": "1800000013640000000000000000000000000000002EB000", + "string": "-0.000000000", + "match_string": "-0E-9" + }, + { + "description": "[basx602] Zeros", + "subject": "180000001364000000000000000000000000000000303000", + "string": "0.00000000", + "match_string": "0E-8" + }, + { + "description": "[basx621] Zeros", + "subject": "18000000136400000000000000000000000000000030B000", + "string": "-0.00000000", + "match_string": "-0E-8" + }, + { + "description": "[basx603] Zeros", + "subject": "180000001364000000000000000000000000000000323000", + "string": "0.0000000", + "match_string": "0E-7" + }, + { + "description": "[basx620] Zeros", + "subject": "18000000136400000000000000000000000000000032B000", + "string": "-0.0000000", + "match_string": "-0E-7" + }, + { + "description": "[basx604] Zeros", + "subject": "180000001364000000000000000000000000000000343000", + "string": "0.000000" + }, + { + "description": "[basx619] Zeros", + "subject": "18000000136400000000000000000000000000000034B000", + "string": "-0.000000" + }, + { + "description": "[basx605] Zeros", + "subject": "180000001364000000000000000000000000000000363000", + "string": "0.00000" + }, + { + "description": "[basx618] Zeros", + "subject": "18000000136400000000000000000000000000000036B000", + "string": "-0.00000" + }, + { + "description": "[basx680] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "000000.", + "match_string": "0" + }, + { + "description": "[basx606] Zeros", + "subject": "180000001364000000000000000000000000000000383000", + "string": "0.0000" + }, + { + "description": "[basx617] Zeros", + "subject": "18000000136400000000000000000000000000000038B000", + "string": "-0.0000" + }, + { + "description": "[basx681] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "00000.", + "match_string": "0" + }, + { + "description": "[basx686] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "+00000.", + "match_string": "0" + }, + { + "description": "[basx687] Zeros", + "subject": "18000000136400000000000000000000000000000040B000", + "string": "-00000.", + "match_string": "-0" + }, + { + "description": "[basx019] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640000000000000000000000000000003CB000", + "string": "-00.00", + "match_string": "-0.00" + }, + { + "description": "[basx607] Zeros", + "subject": "1800000013640000000000000000000000000000003A3000", + "string": "0.000" + }, + { + "description": "[basx616] Zeros", + "subject": "1800000013640000000000000000000000000000003AB000", + "string": "-0.000" + }, + { + "description": "[basx682] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "0000.", + "match_string": "0" + }, + { + "description": "[basx155] Numbers with E", + "subject": "1800000013640000000000000000000000000000003A3000", + "string": "0.000e+0", + "match_string": "0.000" + }, + { + "description": "[basx130] Numbers with E", + "subject": "180000001364000000000000000000000000000000383000", + "string": "0.000E-1", + "match_string": "0.0000" + }, + { + "description": "[basx290] some more negative zeros [systematic tests below]", + "subject": "18000000136400000000000000000000000000000038B000", + "string": "-0.000E-1", + "match_string": "-0.0000" + }, + { + "description": "[basx131] Numbers with E", + "subject": "180000001364000000000000000000000000000000363000", + "string": "0.000E-2", + "match_string": "0.00000" + }, + { + "description": "[basx291] some more negative zeros [systematic tests below]", + "subject": "18000000136400000000000000000000000000000036B000", + "string": "-0.000E-2", + "match_string": "-0.00000" + }, + { + "description": "[basx132] Numbers with E", + "subject": "180000001364000000000000000000000000000000343000", + "string": "0.000E-3", + "match_string": "0.000000" + }, + { + "description": "[basx292] some more negative zeros [systematic tests below]", + "subject": "18000000136400000000000000000000000000000034B000", + "string": "-0.000E-3", + "match_string": "-0.000000" + }, + { + "description": "[basx133] Numbers with E", + "subject": "180000001364000000000000000000000000000000323000", + "string": "0.000E-4", + "match_string": "0E-7" + }, + { + "description": "[basx293] some more negative zeros [systematic tests below]", + "subject": "18000000136400000000000000000000000000000032B000", + "string": "-0.000E-4", + "match_string": "-0E-7" + }, + { + "description": "[basx608] Zeros", + "subject": "1800000013640000000000000000000000000000003C3000", + "string": "0.00" + }, + { + "description": "[basx615] Zeros", + "subject": "1800000013640000000000000000000000000000003CB000", + "string": "-0.00" + }, + { + "description": "[basx683] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "000.", + "match_string": "0" + }, + { + "description": "[basx630] Zeros", + "subject": "1800000013640000000000000000000000000000003C3000", + "string": "0.00E+0", + "match_string": "0.00" + }, + { + "description": "[basx670] Zeros", + "subject": "1800000013640000000000000000000000000000003C3000", + "string": "0.00E-0", + "match_string": "0.00" + }, + { + "description": "[basx631] Zeros", + "subject": "1800000013640000000000000000000000000000003E3000", + "string": "0.00E+1", + "match_string": "0.0" + }, + { + "description": "[basx671] Zeros", + "subject": "1800000013640000000000000000000000000000003A3000", + "string": "0.00E-1", + "match_string": "0.000" + }, + { + "description": "[basx134] Numbers with E", + "subject": "180000001364000000000000000000000000000000383000", + "string": "0.00E-2", + "match_string": "0.0000" + }, + { + "description": "[basx294] some more negative zeros [systematic tests below]", + "subject": "18000000136400000000000000000000000000000038B000", + "string": "-0.00E-2", + "match_string": "-0.0000" + }, + { + "description": "[basx632] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "0.00E+2", + "match_string": "0" + }, + { + "description": "[basx672] Zeros", + "subject": "180000001364000000000000000000000000000000383000", + "string": "0.00E-2", + "match_string": "0.0000" + }, + { + "description": "[basx135] Numbers with E", + "subject": "180000001364000000000000000000000000000000363000", + "string": "0.00E-3", + "match_string": "0.00000" + }, + { + "description": "[basx295] some more negative zeros [systematic tests below]", + "subject": "18000000136400000000000000000000000000000036B000", + "string": "-0.00E-3", + "match_string": "-0.00000" + }, + { + "description": "[basx633] Zeros", + "subject": "180000001364000000000000000000000000000000423000", + "string": "0.00E+3", + "match_string": "0E+1" + }, + { + "description": "[basx673] Zeros", + "subject": "180000001364000000000000000000000000000000363000", + "string": "0.00E-3", + "match_string": "0.00000" + }, + { + "description": "[basx136] Numbers with E", + "subject": "180000001364000000000000000000000000000000343000", + "string": "0.00E-4", + "match_string": "0.000000" + }, + { + "description": "[basx674] Zeros", + "subject": "180000001364000000000000000000000000000000343000", + "string": "0.00E-4", + "match_string": "0.000000" + }, + { + "description": "[basx634] Zeros", + "subject": "180000001364000000000000000000000000000000443000", + "string": "0.00E+4", + "match_string": "0E+2" + }, + { + "description": "[basx137] Numbers with E", + "subject": "180000001364000000000000000000000000000000323000", + "string": "0.00E-5", + "match_string": "0E-7" + }, + { + "description": "[basx635] Zeros", + "subject": "180000001364000000000000000000000000000000463000", + "string": "0.00E+5", + "match_string": "0E+3" + }, + { + "description": "[basx675] Zeros", + "subject": "180000001364000000000000000000000000000000323000", + "string": "0.00E-5", + "match_string": "0E-7" + }, + { + "description": "[basx636] Zeros", + "subject": "180000001364000000000000000000000000000000483000", + "string": "0.00E+6", + "match_string": "0E+4" + }, + { + "description": "[basx676] Zeros", + "subject": "180000001364000000000000000000000000000000303000", + "string": "0.00E-6", + "match_string": "0E-8" + }, + { + "description": "[basx637] Zeros", + "subject": "1800000013640000000000000000000000000000004A3000", + "string": "0.00E+7", + "match_string": "0E+5" + }, + { + "description": "[basx677] Zeros", + "subject": "1800000013640000000000000000000000000000002E3000", + "string": "0.00E-7", + "match_string": "0E-9" + }, + { + "description": "[basx638] Zeros", + "subject": "1800000013640000000000000000000000000000004C3000", + "string": "0.00E+8", + "match_string": "0E+6" + }, + { + "description": "[basx678] Zeros", + "subject": "1800000013640000000000000000000000000000002C3000", + "string": "0.00E-8", + "match_string": "0E-10" + }, + { + "description": "[basx149] Numbers with E", + "subject": "180000001364000000000000000000000000000000523000", + "string": "000E+9", + "match_string": "0E+9" + }, + { + "description": "[basx639] Zeros", + "subject": "1800000013640000000000000000000000000000004E3000", + "string": "0.00E+9", + "match_string": "0E+7" + }, + { + "description": "[basx679] Zeros", + "subject": "1800000013640000000000000000000000000000002A3000", + "string": "0.00E-9", + "match_string": "0E-11" + }, + { + "description": "[basx063] strings without E cannot generate E in result", + "subject": "18000000136400185C0ACE00000000000000000000383000", + "string": "+00345678.5432", + "match_string": "345678.5432" + }, + { + "description": "[basx018] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640000000000000000000000000000003EB000", + "string": "-0.0" + }, + { + "description": "[basx609] Zeros", + "subject": "1800000013640000000000000000000000000000003E3000", + "string": "0.0" + }, + { + "description": "[basx614] Zeros", + "subject": "1800000013640000000000000000000000000000003EB000", + "string": "-0.0" + }, + { + "description": "[basx684] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "00.", + "match_string": "0" + }, + { + "description": "[basx640] Zeros", + "subject": "1800000013640000000000000000000000000000003E3000", + "string": "0.0E+0", + "match_string": "0.0" + }, + { + "description": "[basx660] Zeros", + "subject": "1800000013640000000000000000000000000000003E3000", + "string": "0.0E-0", + "match_string": "0.0" + }, + { + "description": "[basx641] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "0.0E+1", + "match_string": "0" + }, + { + "description": "[basx661] Zeros", + "subject": "1800000013640000000000000000000000000000003C3000", + "string": "0.0E-1", + "match_string": "0.00" + }, + { + "description": "[basx296] some more negative zeros [systematic tests below]", + "subject": "1800000013640000000000000000000000000000003AB000", + "string": "-0.0E-2", + "match_string": "-0.000" + }, + { + "description": "[basx642] Zeros", + "subject": "180000001364000000000000000000000000000000423000", + "string": "0.0E+2", + "match_string": "0E+1" + }, + { + "description": "[basx662] Zeros", + "subject": "1800000013640000000000000000000000000000003A3000", + "string": "0.0E-2", + "match_string": "0.000" + }, + { + "description": "[basx297] some more negative zeros [systematic tests below]", + "subject": "18000000136400000000000000000000000000000038B000", + "string": "-0.0E-3", + "match_string": "-0.0000" + }, + { + "description": "[basx643] Zeros", + "subject": "180000001364000000000000000000000000000000443000", + "string": "0.0E+3", + "match_string": "0E+2" + }, + { + "description": "[basx663] Zeros", + "subject": "180000001364000000000000000000000000000000383000", + "string": "0.0E-3", + "match_string": "0.0000" + }, + { + "description": "[basx644] Zeros", + "subject": "180000001364000000000000000000000000000000463000", + "string": "0.0E+4", + "match_string": "0E+3" + }, + { + "description": "[basx664] Zeros", + "subject": "180000001364000000000000000000000000000000363000", + "string": "0.0E-4", + "match_string": "0.00000" + }, + { + "description": "[basx645] Zeros", + "subject": "180000001364000000000000000000000000000000483000", + "string": "0.0E+5", + "match_string": "0E+4" + }, + { + "description": "[basx665] Zeros", + "subject": "180000001364000000000000000000000000000000343000", + "string": "0.0E-5", + "match_string": "0.000000" + }, + { + "description": "[basx646] Zeros", + "subject": "1800000013640000000000000000000000000000004A3000", + "string": "0.0E+6", + "match_string": "0E+5" + }, + { + "description": "[basx666] Zeros", + "subject": "180000001364000000000000000000000000000000323000", + "string": "0.0E-6", + "match_string": "0E-7" + }, + { + "description": "[basx647] Zeros", + "subject": "1800000013640000000000000000000000000000004C3000", + "string": "0.0E+7", + "match_string": "0E+6" + }, + { + "description": "[basx667] Zeros", + "subject": "180000001364000000000000000000000000000000303000", + "string": "0.0E-7", + "match_string": "0E-8" + }, + { + "description": "[basx648] Zeros", + "subject": "1800000013640000000000000000000000000000004E3000", + "string": "0.0E+8", + "match_string": "0E+7" + }, + { + "description": "[basx668] Zeros", + "subject": "1800000013640000000000000000000000000000002E3000", + "string": "0.0E-8", + "match_string": "0E-9" + }, + { + "description": "[basx160] Numbers with E", + "subject": "180000001364000000000000000000000000000000523000", + "string": "00E+9", + "match_string": "0E+9" + }, + { + "description": "[basx161] Numbers with E", + "subject": "1800000013640000000000000000000000000000002E3000", + "string": "00E-9", + "match_string": "0E-9" + }, + { + "description": "[basx649] Zeros", + "subject": "180000001364000000000000000000000000000000503000", + "string": "0.0E+9", + "match_string": "0E+8" + }, + { + "description": "[basx669] Zeros", + "subject": "1800000013640000000000000000000000000000002C3000", + "string": "0.0E-9", + "match_string": "0E-10" + }, + { + "description": "[basx062] strings without E cannot generate E in result", + "subject": "18000000136400185C0ACE00000000000000000000383000", + "string": "+0345678.5432", + "match_string": "345678.5432" + }, + { + "description": "[basx001] conform to rules and exponent will be in permitted range).", + "subject": "180000001364000000000000000000000000000000403000", + "string": "0" + }, + { + "description": "[basx017] conform to rules and exponent will be in permitted range).", + "subject": "18000000136400000000000000000000000000000040B000", + "string": "-0" + }, + { + "description": "[basx611] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "0.", + "match_string": "0" + }, + { + "description": "[basx613] Zeros", + "subject": "18000000136400000000000000000000000000000040B000", + "string": "-0.", + "match_string": "-0" + }, + { + "description": "[basx685] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "0.", + "match_string": "0" + }, + { + "description": "[basx688] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "+0.", + "match_string": "0" + }, + { + "description": "[basx689] Zeros", + "subject": "18000000136400000000000000000000000000000040B000", + "string": "-0.", + "match_string": "-0" + }, + { + "description": "[basx650] Zeros", + "subject": "180000001364000000000000000000000000000000403000", + "string": "0E+0", + "match_string": "0" + }, + { + "description": "[basx651] Zeros", + "subject": "180000001364000000000000000000000000000000423000", + "string": "0E+1" + }, + { + "description": "[basx298] some more negative zeros [systematic tests below]", + "subject": "1800000013640000000000000000000000000000003CB000", + "string": "-0E-2", + "match_string": "-0.00" + }, + { + "description": "[basx652] Zeros", + "subject": "180000001364000000000000000000000000000000443000", + "string": "0E+2" + }, + { + "description": "[basx299] some more negative zeros [systematic tests below]", + "subject": "1800000013640000000000000000000000000000003AB000", + "string": "-0E-3", + "match_string": "-0.000" + }, + { + "description": "[basx653] Zeros", + "subject": "180000001364000000000000000000000000000000463000", + "string": "0E+3" + }, + { + "description": "[basx654] Zeros", + "subject": "180000001364000000000000000000000000000000483000", + "string": "0E+4" + }, + { + "description": "[basx655] Zeros", + "subject": "1800000013640000000000000000000000000000004A3000", + "string": "0E+5" + }, + { + "description": "[basx656] Zeros", + "subject": "1800000013640000000000000000000000000000004C3000", + "string": "0E+6" + }, + { + "description": "[basx657] Zeros", + "subject": "1800000013640000000000000000000000000000004E3000", + "string": "0E+7" + }, + { + "description": "[basx658] Zeros", + "subject": "180000001364000000000000000000000000000000503000", + "string": "0E+8" + }, + { + "description": "[basx138] Numbers with E", + "subject": "180000001364000000000000000000000000000000523000", + "string": "+0E+9", + "match_string": "0E+9" + }, + { + "description": "[basx139] Numbers with E", + "subject": "18000000136400000000000000000000000000000052B000", + "string": "-0E+9" + }, + { + "description": "[basx144] Numbers with E", + "subject": "180000001364000000000000000000000000000000523000", + "string": "0E+9" + }, + { + "description": "[basx154] Numbers with E", + "subject": "180000001364000000000000000000000000000000523000", + "string": "0E9", + "match_string": "0E+9" + }, + { + "description": "[basx659] Zeros", + "subject": "180000001364000000000000000000000000000000523000", + "string": "0E+9" + }, + { + "description": "[basx042] strings without E cannot generate E in result", + "subject": "18000000136400FC040000000000000000000000003C3000", + "string": "+12.76", + "match_string": "12.76" + }, + { + "description": "[basx143] Numbers with E", + "subject": "180000001364000100000000000000000000000000523000", + "string": "+1E+009", + "match_string": "1E+9" + }, + { + "description": "[basx061] strings without E cannot generate E in result", + "subject": "18000000136400185C0ACE00000000000000000000383000", + "string": "+345678.5432", + "match_string": "345678.5432" + }, + { + "description": "[basx036] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640015CD5B0700000000000000000000203000", + "string": "0.0000000123456789", + "match_string": "1.23456789E-8" + }, + { + "description": "[basx035] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640015CD5B0700000000000000000000223000", + "string": "0.000000123456789", + "match_string": "1.23456789E-7" + }, + { + "description": "[basx034] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640015CD5B0700000000000000000000243000", + "string": "0.00000123456789" + }, + { + "description": "[basx053] strings without E cannot generate E in result", + "subject": "180000001364003200000000000000000000000000323000", + "string": "0.0000050" + }, + { + "description": "[basx033] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640015CD5B0700000000000000000000263000", + "string": "0.0000123456789" + }, + { + "description": "[basx016] conform to rules and exponent will be in permitted range).", + "subject": "180000001364000C000000000000000000000000003A3000", + "string": "0.012" + }, + { + "description": "[basx015] conform to rules and exponent will be in permitted range).", + "subject": "180000001364007B000000000000000000000000003A3000", + "string": "0.123" + }, + { + "description": "[basx037] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640078DF0D8648700000000000000000223000", + "string": "0.123456789012344" + }, + { + "description": "[basx038] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640079DF0D8648700000000000000000223000", + "string": "0.123456789012345" + }, + { + "description": "[basx250] Numbers with E", + "subject": "18000000136400F104000000000000000000000000383000", + "string": "0.1265" + }, + { + "description": "[basx257] Numbers with E", + "subject": "18000000136400F104000000000000000000000000383000", + "string": "0.1265E-0", + "match_string": "0.1265" + }, + { + "description": "[basx256] Numbers with E", + "subject": "18000000136400F104000000000000000000000000363000", + "string": "0.1265E-1", + "match_string": "0.01265" + }, + { + "description": "[basx258] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003A3000", + "string": "0.1265E+1", + "match_string": "1.265" + }, + { + "description": "[basx251] Numbers with E", + "subject": "18000000136400F104000000000000000000000000103000", + "string": "0.1265E-20", + "match_string": "1.265E-21" + }, + { + "description": "[basx263] Numbers with E", + "subject": "18000000136400F104000000000000000000000000603000", + "string": "0.1265E+20", + "match_string": "1.265E+19" + }, + { + "description": "[basx255] Numbers with E", + "subject": "18000000136400F104000000000000000000000000343000", + "string": "0.1265E-2", + "match_string": "0.001265" + }, + { + "description": "[basx259] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003C3000", + "string": "0.1265E+2", + "match_string": "12.65" + }, + { + "description": "[basx254] Numbers with E", + "subject": "18000000136400F104000000000000000000000000323000", + "string": "0.1265E-3", + "match_string": "0.0001265" + }, + { + "description": "[basx260] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003E3000", + "string": "0.1265E+3", + "match_string": "126.5" + }, + { + "description": "[basx253] Numbers with E", + "subject": "18000000136400F104000000000000000000000000303000", + "string": "0.1265E-4", + "match_string": "0.00001265" + }, + { + "description": "[basx261] Numbers with E", + "subject": "18000000136400F104000000000000000000000000403000", + "string": "0.1265E+4", + "match_string": "1265" + }, + { + "description": "[basx252] Numbers with E", + "subject": "18000000136400F104000000000000000000000000283000", + "string": "0.1265E-8", + "match_string": "1.265E-9" + }, + { + "description": "[basx262] Numbers with E", + "subject": "18000000136400F104000000000000000000000000483000", + "string": "0.1265E+8", + "match_string": "1.265E+7" + }, + { + "description": "[basx159] Numbers with E", + "subject": "1800000013640049000000000000000000000000002E3000", + "string": "0.73e-7", + "match_string": "7.3E-8" + }, + { + "description": "[basx004] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640064000000000000000000000000003C3000", + "string": "1.00" + }, + { + "description": "[basx003] conform to rules and exponent will be in permitted range).", + "subject": "180000001364000A000000000000000000000000003E3000", + "string": "1.0" + }, + { + "description": "[basx002] conform to rules and exponent will be in permitted range).", + "subject": "180000001364000100000000000000000000000000403000", + "string": "1" + }, + { + "description": "[basx148] Numbers with E", + "subject": "180000001364000100000000000000000000000000523000", + "string": "1E+009", + "match_string": "1E+9" + }, + { + "description": "[basx153] Numbers with E", + "subject": "180000001364000100000000000000000000000000523000", + "string": "1E009", + "match_string": "1E+9" + }, + { + "description": "[basx141] Numbers with E", + "subject": "180000001364000100000000000000000000000000523000", + "string": "1e+09", + "match_string": "1E+9" + }, + { + "description": "[basx146] Numbers with E", + "subject": "180000001364000100000000000000000000000000523000", + "string": "1E+09", + "match_string": "1E+9" + }, + { + "description": "[basx151] Numbers with E", + "subject": "180000001364000100000000000000000000000000523000", + "string": "1e09", + "match_string": "1E+9" + }, + { + "description": "[basx142] Numbers with E", + "subject": "180000001364000100000000000000000000000000F43000", + "string": "1E+90" + }, + { + "description": "[basx147] Numbers with E", + "subject": "180000001364000100000000000000000000000000F43000", + "string": "1e+90", + "match_string": "1E+90" + }, + { + "description": "[basx152] Numbers with E", + "subject": "180000001364000100000000000000000000000000F43000", + "string": "1E90", + "match_string": "1E+90" + }, + { + "description": "[basx140] Numbers with E", + "subject": "180000001364000100000000000000000000000000523000", + "string": "1E+9" + }, + { + "description": "[basx150] Numbers with E", + "subject": "180000001364000100000000000000000000000000523000", + "string": "1E9", + "match_string": "1E+9" + }, + { + "description": "[basx014] conform to rules and exponent will be in permitted range).", + "subject": "18000000136400D2040000000000000000000000003A3000", + "string": "1.234" + }, + { + "description": "[basx170] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003A3000", + "string": "1.265" + }, + { + "description": "[basx177] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003A3000", + "string": "1.265E-0", + "match_string": "1.265" + }, + { + "description": "[basx176] Numbers with E", + "subject": "18000000136400F104000000000000000000000000383000", + "string": "1.265E-1", + "match_string": "0.1265" + }, + { + "description": "[basx178] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003C3000", + "string": "1.265E+1", + "match_string": "12.65" + }, + { + "description": "[basx171] Numbers with E", + "subject": "18000000136400F104000000000000000000000000123000", + "string": "1.265E-20" + }, + { + "description": "[basx183] Numbers with E", + "subject": "18000000136400F104000000000000000000000000623000", + "string": "1.265E+20" + }, + { + "description": "[basx175] Numbers with E", + "subject": "18000000136400F104000000000000000000000000363000", + "string": "1.265E-2", + "match_string": "0.01265" + }, + { + "description": "[basx179] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003E3000", + "string": "1.265E+2", + "match_string": "126.5" + }, + { + "description": "[basx174] Numbers with E", + "subject": "18000000136400F104000000000000000000000000343000", + "string": "1.265E-3", + "match_string": "0.001265" + }, + { + "description": "[basx180] Numbers with E", + "subject": "18000000136400F104000000000000000000000000403000", + "string": "1.265E+3", + "match_string": "1265" + }, + { + "description": "[basx173] Numbers with E", + "subject": "18000000136400F104000000000000000000000000323000", + "string": "1.265E-4", + "match_string": "0.0001265" + }, + { + "description": "[basx181] Numbers with E", + "subject": "18000000136400F104000000000000000000000000423000", + "string": "1.265E+4" + }, + { + "description": "[basx172] Numbers with E", + "subject": "18000000136400F1040000000000000000000000002A3000", + "string": "1.265E-8" + }, + { + "description": "[basx182] Numbers with E", + "subject": "18000000136400F1040000000000000000000000004A3000", + "string": "1.265E+8" + }, + { + "description": "[basx157] Numbers with E", + "subject": "180000001364000400000000000000000000000000523000", + "string": "4E+9" + }, + { + "description": "[basx067] examples", + "subject": "180000001364000500000000000000000000000000343000", + "string": "5E-6", + "match_string": "0.000005" + }, + { + "description": "[basx069] examples", + "subject": "180000001364000500000000000000000000000000323000", + "string": "5E-7" + }, + { + "description": "[basx385] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000403000", + "string": "7E0", + "match_string": "7" + }, + { + "description": "[basx365] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000543000", + "string": "7E10", + "match_string": "7E+10" + }, + { + "description": "[basx405] Engineering notation tests", + "subject": "1800000013640007000000000000000000000000002C3000", + "string": "7E-10" + }, + { + "description": "[basx363] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000563000", + "string": "7E11", + "match_string": "7E+11" + }, + { + "description": "[basx407] Engineering notation tests", + "subject": "1800000013640007000000000000000000000000002A3000", + "string": "7E-11" + }, + { + "description": "[basx361] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000583000", + "string": "7E12", + "match_string": "7E+12" + }, + { + "description": "[basx409] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000283000", + "string": "7E-12" + }, + { + "description": "[basx411] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000263000", + "string": "7E-13" + }, + { + "description": "[basx383] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000423000", + "string": "7E1", + "match_string": "7E+1" + }, + { + "description": "[basx387] Engineering notation tests", + "subject": "1800000013640007000000000000000000000000003E3000", + "string": "7E-1", + "match_string": "0.7" + }, + { + "description": "[basx381] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000443000", + "string": "7E2", + "match_string": "7E+2" + }, + { + "description": "[basx389] Engineering notation tests", + "subject": "1800000013640007000000000000000000000000003C3000", + "string": "7E-2", + "match_string": "0.07" + }, + { + "description": "[basx379] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000463000", + "string": "7E3", + "match_string": "7E+3" + }, + { + "description": "[basx391] Engineering notation tests", + "subject": "1800000013640007000000000000000000000000003A3000", + "string": "7E-3", + "match_string": "0.007" + }, + { + "description": "[basx377] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000483000", + "string": "7E4", + "match_string": "7E+4" + }, + { + "description": "[basx393] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000383000", + "string": "7E-4", + "match_string": "0.0007" + }, + { + "description": "[basx375] Engineering notation tests", + "subject": "1800000013640007000000000000000000000000004A3000", + "string": "7E5", + "match_string": "7E+5" + }, + { + "description": "[basx395] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000363000", + "string": "7E-5", + "match_string": "0.00007" + }, + { + "description": "[basx373] Engineering notation tests", + "subject": "1800000013640007000000000000000000000000004C3000", + "string": "7E6", + "match_string": "7E+6" + }, + { + "description": "[basx397] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000343000", + "string": "7E-6", + "match_string": "0.000007" + }, + { + "description": "[basx371] Engineering notation tests", + "subject": "1800000013640007000000000000000000000000004E3000", + "string": "7E7", + "match_string": "7E+7" + }, + { + "description": "[basx399] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000323000", + "string": "7E-7" + }, + { + "description": "[basx369] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000503000", + "string": "7E8", + "match_string": "7E+8" + }, + { + "description": "[basx401] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000303000", + "string": "7E-8" + }, + { + "description": "[basx367] Engineering notation tests", + "subject": "180000001364000700000000000000000000000000523000", + "string": "7E9", + "match_string": "7E+9" + }, + { + "description": "[basx403] Engineering notation tests", + "subject": "1800000013640007000000000000000000000000002E3000", + "string": "7E-9" + }, + { + "description": "[basx007] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640064000000000000000000000000003E3000", + "string": "10.0" + }, + { + "description": "[basx005] conform to rules and exponent will be in permitted range).", + "subject": "180000001364000A00000000000000000000000000403000", + "string": "10" + }, + { + "description": "[basx165] Numbers with E", + "subject": "180000001364000A00000000000000000000000000523000", + "string": "10E+009", + "match_string": "1.0E+10" + }, + { + "description": "[basx163] Numbers with E", + "subject": "180000001364000A00000000000000000000000000523000", + "string": "10E+09", + "match_string": "1.0E+10" + }, + { + "description": "[basx325] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000403000", + "string": "10e0", + "match_string": "10" + }, + { + "description": "[basx305] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000543000", + "string": "10e10", + "match_string": "1.0E+11" + }, + { + "description": "[basx345] Engineering notation tests", + "subject": "180000001364000A000000000000000000000000002C3000", + "string": "10e-10", + "match_string": "1.0E-9" + }, + { + "description": "[basx303] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000563000", + "string": "10e11", + "match_string": "1.0E+12" + }, + { + "description": "[basx347] Engineering notation tests", + "subject": "180000001364000A000000000000000000000000002A3000", + "string": "10e-11", + "match_string": "1.0E-10" + }, + { + "description": "[basx301] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000583000", + "string": "10e12", + "match_string": "1.0E+13" + }, + { + "description": "[basx349] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000283000", + "string": "10e-12", + "match_string": "1.0E-11" + }, + { + "description": "[basx351] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000263000", + "string": "10e-13", + "match_string": "1.0E-12" + }, + { + "description": "[basx323] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000423000", + "string": "10e1", + "match_string": "1.0E+2" + }, + { + "description": "[basx327] Engineering notation tests", + "subject": "180000001364000A000000000000000000000000003E3000", + "string": "10e-1", + "match_string": "1.0" + }, + { + "description": "[basx321] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000443000", + "string": "10e2", + "match_string": "1.0E+3" + }, + { + "description": "[basx329] Engineering notation tests", + "subject": "180000001364000A000000000000000000000000003C3000", + "string": "10e-2", + "match_string": "0.10" + }, + { + "description": "[basx319] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000463000", + "string": "10e3", + "match_string": "1.0E+4" + }, + { + "description": "[basx331] Engineering notation tests", + "subject": "180000001364000A000000000000000000000000003A3000", + "string": "10e-3", + "match_string": "0.010" + }, + { + "description": "[basx317] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000483000", + "string": "10e4", + "match_string": "1.0E+5" + }, + { + "description": "[basx333] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000383000", + "string": "10e-4", + "match_string": "0.0010" + }, + { + "description": "[basx315] Engineering notation tests", + "subject": "180000001364000A000000000000000000000000004A3000", + "string": "10e5", + "match_string": "1.0E+6" + }, + { + "description": "[basx335] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000363000", + "string": "10e-5", + "match_string": "0.00010" + }, + { + "description": "[basx313] Engineering notation tests", + "subject": "180000001364000A000000000000000000000000004C3000", + "string": "10e6", + "match_string": "1.0E+7" + }, + { + "description": "[basx337] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000343000", + "string": "10e-6", + "match_string": "0.000010" + }, + { + "description": "[basx311] Engineering notation tests", + "subject": "180000001364000A000000000000000000000000004E3000", + "string": "10e7", + "match_string": "1.0E+8" + }, + { + "description": "[basx339] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000323000", + "string": "10e-7", + "match_string": "0.0000010" + }, + { + "description": "[basx309] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000503000", + "string": "10e8", + "match_string": "1.0E+9" + }, + { + "description": "[basx341] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000303000", + "string": "10e-8", + "match_string": "1.0E-7" + }, + { + "description": "[basx164] Numbers with E", + "subject": "180000001364000A00000000000000000000000000F43000", + "string": "10e+90", + "match_string": "1.0E+91" + }, + { + "description": "[basx162] Numbers with E", + "subject": "180000001364000A00000000000000000000000000523000", + "string": "10E+9", + "match_string": "1.0E+10" + }, + { + "description": "[basx307] Engineering notation tests", + "subject": "180000001364000A00000000000000000000000000523000", + "string": "10e9", + "match_string": "1.0E+10" + }, + { + "description": "[basx343] Engineering notation tests", + "subject": "180000001364000A000000000000000000000000002E3000", + "string": "10e-9", + "match_string": "1.0E-8" + }, + { + "description": "[basx008] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640065000000000000000000000000003E3000", + "string": "10.1" + }, + { + "description": "[basx009] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640068000000000000000000000000003E3000", + "string": "10.4" + }, + { + "description": "[basx010] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640069000000000000000000000000003E3000", + "string": "10.5" + }, + { + "description": "[basx011] conform to rules and exponent will be in permitted range).", + "subject": "180000001364006A000000000000000000000000003E3000", + "string": "10.6" + }, + { + "description": "[basx012] conform to rules and exponent will be in permitted range).", + "subject": "180000001364006D000000000000000000000000003E3000", + "string": "10.9" + }, + { + "description": "[basx013] conform to rules and exponent will be in permitted range).", + "subject": "180000001364006E000000000000000000000000003E3000", + "string": "11.0" + }, + { + "description": "[basx040] strings without E cannot generate E in result", + "subject": "180000001364000C00000000000000000000000000403000", + "string": "12" + }, + { + "description": "[basx190] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003C3000", + "string": "12.65" + }, + { + "description": "[basx197] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003C3000", + "string": "12.65E-0", + "match_string": "12.65" + }, + { + "description": "[basx196] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003A3000", + "string": "12.65E-1", + "match_string": "1.265" + }, + { + "description": "[basx198] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003E3000", + "string": "12.65E+1", + "match_string": "126.5" + }, + { + "description": "[basx191] Numbers with E", + "subject": "18000000136400F104000000000000000000000000143000", + "string": "12.65E-20", + "match_string": "1.265E-19" + }, + { + "description": "[basx203] Numbers with E", + "subject": "18000000136400F104000000000000000000000000643000", + "string": "12.65E+20", + "match_string": "1.265E+21" + }, + { + "description": "[basx195] Numbers with E", + "subject": "18000000136400F104000000000000000000000000383000", + "string": "12.65E-2", + "match_string": "0.1265" + }, + { + "description": "[basx199] Numbers with E", + "subject": "18000000136400F104000000000000000000000000403000", + "string": "12.65E+2", + "match_string": "1265" + }, + { + "description": "[basx194] Numbers with E", + "subject": "18000000136400F104000000000000000000000000363000", + "string": "12.65E-3", + "match_string": "0.01265" + }, + { + "description": "[basx200] Numbers with E", + "subject": "18000000136400F104000000000000000000000000423000", + "string": "12.65E+3", + "match_string": "1.265E+4" + }, + { + "description": "[basx193] Numbers with E", + "subject": "18000000136400F104000000000000000000000000343000", + "string": "12.65E-4", + "match_string": "0.001265" + }, + { + "description": "[basx201] Numbers with E", + "subject": "18000000136400F104000000000000000000000000443000", + "string": "12.65E+4", + "match_string": "1.265E+5" + }, + { + "description": "[basx192] Numbers with E", + "subject": "18000000136400F1040000000000000000000000002C3000", + "string": "12.65E-8", + "match_string": "1.265E-7" + }, + { + "description": "[basx202] Numbers with E", + "subject": "18000000136400F1040000000000000000000000004C3000", + "string": "12.65E+8", + "match_string": "1.265E+9" + }, + { + "description": "[basx044] strings without E cannot generate E in result", + "subject": "18000000136400FC040000000000000000000000003C3000", + "string": "012.76", + "match_string": "12.76" + }, + { + "description": "[basx042] strings without E cannot generate E in result", + "subject": "18000000136400FC040000000000000000000000003C3000", + "string": "12.76" + }, + { + "description": "[basx046] strings without E cannot generate E in result", + "subject": "180000001364001100000000000000000000000000403000", + "string": "17.", + "match_string": "17" + }, + { + "description": "[basx049] strings without E cannot generate E in result", + "subject": "180000001364002C00000000000000000000000000403000", + "string": "0044", + "match_string": "44" + }, + { + "description": "[basx048] strings without E cannot generate E in result", + "subject": "180000001364002C00000000000000000000000000403000", + "string": "044", + "match_string": "44" + }, + { + "description": "[basx158] Numbers with E", + "subject": "180000001364002C00000000000000000000000000523000", + "string": "44E+9", + "match_string": "4.4E+10" + }, + { + "description": "[basx068] examples", + "subject": "180000001364003200000000000000000000000000323000", + "string": "50E-7", + "match_string": "0.0000050" + }, + { + "description": "[basx169] Numbers with E", + "subject": "180000001364006400000000000000000000000000523000", + "string": "100e+009", + "match_string": "1.00E+11" + }, + { + "description": "[basx167] Numbers with E", + "subject": "180000001364006400000000000000000000000000523000", + "string": "100e+09", + "match_string": "1.00E+11" + }, + { + "description": "[basx168] Numbers with E", + "subject": "180000001364006400000000000000000000000000F43000", + "string": "100E+90", + "match_string": "1.00E+92" + }, + { + "description": "[basx166] Numbers with E", + "subject": "180000001364006400000000000000000000000000523000", + "string": "100e+9", + "match_string": "1.00E+11" + }, + { + "description": "[basx210] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003E3000", + "string": "126.5" + }, + { + "description": "[basx217] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003E3000", + "string": "126.5E-0", + "match_string": "126.5" + }, + { + "description": "[basx216] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003C3000", + "string": "126.5E-1", + "match_string": "12.65" + }, + { + "description": "[basx218] Numbers with E", + "subject": "18000000136400F104000000000000000000000000403000", + "string": "126.5E+1", + "match_string": "1265" + }, + { + "description": "[basx211] Numbers with E", + "subject": "18000000136400F104000000000000000000000000163000", + "string": "126.5E-20", + "match_string": "1.265E-18" + }, + { + "description": "[basx223] Numbers with E", + "subject": "18000000136400F104000000000000000000000000663000", + "string": "126.5E+20", + "match_string": "1.265E+22" + }, + { + "description": "[basx215] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003A3000", + "string": "126.5E-2", + "match_string": "1.265" + }, + { + "description": "[basx219] Numbers with E", + "subject": "18000000136400F104000000000000000000000000423000", + "string": "126.5E+2", + "match_string": "1.265E+4" + }, + { + "description": "[basx214] Numbers with E", + "subject": "18000000136400F104000000000000000000000000383000", + "string": "126.5E-3", + "match_string": "0.1265" + }, + { + "description": "[basx220] Numbers with E", + "subject": "18000000136400F104000000000000000000000000443000", + "string": "126.5E+3", + "match_string": "1.265E+5" + }, + { + "description": "[basx213] Numbers with E", + "subject": "18000000136400F104000000000000000000000000363000", + "string": "126.5E-4", + "match_string": "0.01265" + }, + { + "description": "[basx221] Numbers with E", + "subject": "18000000136400F104000000000000000000000000463000", + "string": "126.5E+4", + "match_string": "1.265E+6" + }, + { + "description": "[basx212] Numbers with E", + "subject": "18000000136400F1040000000000000000000000002E3000", + "string": "126.5E-8", + "match_string": "0.000001265" + }, + { + "description": "[basx222] Numbers with E", + "subject": "18000000136400F1040000000000000000000000004E3000", + "string": "126.5E+8", + "match_string": "1.265E+10" + }, + { + "description": "[basx006] conform to rules and exponent will be in permitted range).", + "subject": "18000000136400E803000000000000000000000000403000", + "string": "1000" + }, + { + "description": "[basx230] Numbers with E", + "subject": "18000000136400F104000000000000000000000000403000", + "string": "1265" + }, + { + "description": "[basx237] Numbers with E", + "subject": "18000000136400F104000000000000000000000000403000", + "string": "1265E-0", + "match_string": "1265" + }, + { + "description": "[basx236] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003E3000", + "string": "1265E-1", + "match_string": "126.5" + }, + { + "description": "[basx238] Numbers with E", + "subject": "18000000136400F104000000000000000000000000423000", + "string": "1265E+1", + "match_string": "1.265E+4" + }, + { + "description": "[basx231] Numbers with E", + "subject": "18000000136400F104000000000000000000000000183000", + "string": "1265E-20", + "match_string": "1.265E-17" + }, + { + "description": "[basx243] Numbers with E", + "subject": "18000000136400F104000000000000000000000000683000", + "string": "1265E+20", + "match_string": "1.265E+23" + }, + { + "description": "[basx235] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003C3000", + "string": "1265E-2", + "match_string": "12.65" + }, + { + "description": "[basx239] Numbers with E", + "subject": "18000000136400F104000000000000000000000000443000", + "string": "1265E+2", + "match_string": "1.265E+5" + }, + { + "description": "[basx234] Numbers with E", + "subject": "18000000136400F1040000000000000000000000003A3000", + "string": "1265E-3", + "match_string": "1.265" + }, + { + "description": "[basx240] Numbers with E", + "subject": "18000000136400F104000000000000000000000000463000", + "string": "1265E+3", + "match_string": "1.265E+6" + }, + { + "description": "[basx233] Numbers with E", + "subject": "18000000136400F104000000000000000000000000383000", + "string": "1265E-4", + "match_string": "0.1265" + }, + { + "description": "[basx241] Numbers with E", + "subject": "18000000136400F104000000000000000000000000483000", + "string": "1265E+4", + "match_string": "1.265E+7" + }, + { + "description": "[basx232] Numbers with E", + "subject": "18000000136400F104000000000000000000000000303000", + "string": "1265E-8", + "match_string": "0.00001265" + }, + { + "description": "[basx242] Numbers with E", + "subject": "18000000136400F104000000000000000000000000503000", + "string": "1265E+8", + "match_string": "1.265E+11" + }, + { + "description": "[basx060] strings without E cannot generate E in result", + "subject": "18000000136400185C0ACE00000000000000000000383000", + "string": "345678.5432" + }, + { + "description": "[basx059] strings without E cannot generate E in result", + "subject": "18000000136400F198670C08000000000000000000363000", + "string": "0345678.54321", + "match_string": "345678.54321" + }, + { + "description": "[basx058] strings without E cannot generate E in result", + "subject": "180000001364006AF90B7C50000000000000000000343000", + "string": "345678.543210" + }, + { + "description": "[basx057] strings without E cannot generate E in result", + "subject": "180000001364006A19562522020000000000000000343000", + "string": "2345678.543210" + }, + { + "description": "[basx056] strings without E cannot generate E in result", + "subject": "180000001364006AB9C8733A0B0000000000000000343000", + "string": "12345678.543210" + }, + { + "description": "[basx031] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640040AF0D8648700000000000000000343000", + "string": "123456789.000000" + }, + { + "description": "[basx030] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640080910F8648700000000000000000343000", + "string": "123456789.123456" + }, + { + "description": "[basx032] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640080910F8648700000000000000000403000", + "string": "123456789123456" + } + ] +} diff --git a/test/decimal/decimal128-4.json b/test/decimal/decimal128-4.json new file mode 100644 index 000000000..6ff127d79 --- /dev/null +++ b/test/decimal/decimal128-4.json @@ -0,0 +1,165 @@ +{ + "description": "Decimal128", + "bson_type": "0x13", + "test_key": "d", + "valid": [ + { + "description": "[basx023] conform to rules and exponent will be in permitted range).", + "subject": "1800000013640001000000000000000000000000003EB000", + "string": "-0.1" + }, + + { + "description": "[basx045] strings without E cannot generate E in result", + "subject": "1800000013640003000000000000000000000000003A3000", + "string": "+0.003", + "match_string": "0.003" + }, + { + "description": "[basx610] Zeros", + "subject": "1800000013640000000000000000000000000000003E3000", + "string": ".0", + "match_string": "0.0" + }, + { + "description": "[basx612] Zeros", + "subject": "1800000013640000000000000000000000000000003EB000", + "string": "-.0", + "match_string": "-0.0" + }, + { + "description": "[basx043] strings without E cannot generate E in result", + "subject": "18000000136400FC040000000000000000000000003C3000", + "string": "+12.76", + "match_string": "12.76" + }, + { + "description": "[basx055] strings without E cannot generate E in result", + "subject": "180000001364000500000000000000000000000000303000", + "string": "0.00000005", + "match_string": "5E-8" + }, + { + "description": "[basx054] strings without E cannot generate E in result", + "subject": "180000001364000500000000000000000000000000323000", + "string": "0.0000005", + "match_string": "5E-7" + }, + { + "description": "[basx052] strings without E cannot generate E in result", + "subject": "180000001364000500000000000000000000000000343000", + "string": "0.000005" + }, + { + "description": "[basx051] strings without E cannot generate E in result", + "subject": "180000001364000500000000000000000000000000363000", + "string": "00.00005", + "match_string": "0.00005" + }, + { + "description": "[basx050] strings without E cannot generate E in result", + "subject": "180000001364000500000000000000000000000000383000", + "string": "0.0005" + }, + { + "description": "[basx047] strings without E cannot generate E in result", + "subject": "1800000013640005000000000000000000000000003E3000", + "string": ".5", + "match_string": "0.5" + }, + { + "description": "[dqbsr431] check rounding modes heeded (Rounded)", + "subject": "1800000013640099761CC7B548F377DC80A131C836FE2F00", + "string": "1.1111111111111111111111111111123450", + "match_string": "1.111111111111111111111111111112345" + }, + { + "description": "OK2", + "subject": "18000000136400000000000A5BC138938D44C64D31FC2F00", + "string": ".100000000000000000000000000000000000000000000000000000000000", + "match_string": "0.1000000000000000000000000000000000" + } + ], + "parseErrors": [ + { + "description": "[basx564] Near-specials (Conversion_syntax)", + "subject": "Infi" + }, + { + "description": "[basx565] Near-specials (Conversion_syntax)", + "subject": "Infin" + }, + { + "description": "[basx566] Near-specials (Conversion_syntax)", + "subject": "Infini" + }, + { + "description": "[basx567] Near-specials (Conversion_syntax)", + "subject": "Infinit" + }, + { + "description": "[basx568] Near-specials (Conversion_syntax)", + "subject": "-Infinit" + }, + { + "description": "[basx590] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": ".Infinity" + }, + { + "description": "[basx562] Near-specials (Conversion_syntax)", + "subject": "NaNq" + }, + { + "description": "[basx563] Near-specials (Conversion_syntax)", + "subject": "NaNs" + }, + { + "description": "[dqbas939] overflow results at different rounding modes (Overflow & Inexact & Rounded)", + "subject": "-7e10000" + }, + { + "description": "[dqbsr534] negatives (Rounded & Inexact)", + "subject": "-1.11111111111111111111111111111234650" + }, + { + "description": "[dqbsr535] negatives (Rounded & Inexact)", + "subject": "-1.11111111111111111111111111111234551" + }, + { + "description": "[dqbsr533] negatives (Rounded & Inexact)", + "subject": "-1.11111111111111111111111111111234550" + }, + { + "description": "[dqbsr532] negatives (Rounded & Inexact)", + "subject": "-1.11111111111111111111111111111234549" + }, + { + "description": "[dqbsr432] check rounding modes heeded (Rounded & Inexact)", + "subject": "1.11111111111111111111111111111234549" + }, + { + "description": "[dqbsr433] check rounding modes heeded (Rounded & Inexact)", + "subject": "1.11111111111111111111111111111234550" + }, + { + "description": "[dqbsr435] check rounding modes heeded (Rounded & Inexact)", + "subject": "1.11111111111111111111111111111234551" + }, + { + "description": "[dqbsr434] check rounding modes heeded (Rounded & Inexact)", + "subject": "1.11111111111111111111111111111234650" + }, + { + "description": "[dqbas938] overflow results at different rounding modes (Overflow & Inexact & Rounded)", + "subject": "7e10000" + }, + { + "description": "Inexact rounding#1", + "subject": "100000000000000000000000000000000000000000000000000000000001" + }, + { + "description": "Inexact rounding#2", + "subject": "1E-6177" + } + ] +} diff --git a/test/decimal/decimal128-5.json b/test/decimal/decimal128-5.json new file mode 100644 index 000000000..2b031a60c --- /dev/null +++ b/test/decimal/decimal128-5.json @@ -0,0 +1,402 @@ +{ + "description": "Decimal128", + "bson_type": "0x13", + "test_key": "d", + "valid": [ + { + "description": "[decq035] fold-downs (more below) (Clamped)", + "subject": "18000000136400000000807F1BCF85B27059C8A43CFE5F00", + "string": "1.23E+6144", + "match_string": "1.230000000000000000000000000000000E+6144" + }, + { + "description": "[decq037] fold-downs (more below) (Clamped)", + "subject": "18000000136400000000000A5BC138938D44C64D31FE5F00", + "string": "1E+6144", + "match_string": "1.000000000000000000000000000000000E+6144" + }, + { + "description": "[decq077] Nmin and below (Subnormal)", + "subject": "180000001364000000000081EFAC855B416D2DEE04000000", + "string": "0.100000000000000000000000000000000E-6143", + "match_string": "1.00000000000000000000000000000000E-6144" + }, + { + "description": "[decq078] Nmin and below (Subnormal)", + "subject": "180000001364000000000081EFAC855B416D2DEE04000000", + "string": "1.00000000000000000000000000000000E-6144" + }, + { + "description": "[decq079] Nmin and below (Subnormal)", + "subject": "180000001364000A00000000000000000000000000000000", + "string": "0.000000000000000000000000000000010E-6143", + "match_string": "1.0E-6175" + }, + { + "description": "[decq080] Nmin and below (Subnormal)", + "subject": "180000001364000A00000000000000000000000000000000", + "string": "1.0E-6175" + }, + { + "description": "[decq081] Nmin and below (Subnormal)", + "subject": "180000001364000100000000000000000000000000020000", + "string": "0.00000000000000000000000000000001E-6143", + "match_string": "1E-6175" + }, + { + "description": "[decq082] Nmin and below (Subnormal)", + "subject": "180000001364000100000000000000000000000000020000", + "string": "1E-6175" + }, + { + "description": "[decq083] Nmin and below (Subnormal)", + "subject": "180000001364000100000000000000000000000000000000", + "string": "0.000000000000000000000000000000001E-6143", + "match_string": "1E-6176" + }, + { + "description": "[decq084] Nmin and below (Subnormal)", + "subject": "180000001364000100000000000000000000000000000000", + "string": "1E-6176" + }, + { + "description": "[decq090] underflows cannot be tested for simple copies, check edge cases (Subnormal)", + "subject": "180000001364000100000000000000000000000000000000", + "string": "1e-6176", + "match_string": "1E-6176" + }, + { + "description": "[decq100] underflows cannot be tested for simple copies, check edge cases (Subnormal)", + "subject": "18000000136400FFFFFFFF095BC138938D44C64D31000000", + "string": "999999999999999999999999999999999e-6176", + "match_string": "9.99999999999999999999999999999999E-6144" + }, + { + "description": "[decq130] fold-downs (more below) (Clamped)", + "subject": "18000000136400000000807F1BCF85B27059C8A43CFEDF00", + "string": "-1.23E+6144", + "match_string": "-1.230000000000000000000000000000000E+6144" + }, + { + "description": "[decq132] fold-downs (more below) (Clamped)", + "subject": "18000000136400000000000A5BC138938D44C64D31FEDF00", + "string": "-1E+6144", + "match_string": "-1.000000000000000000000000000000000E+6144" + }, + { + "description": "[decq177] Nmin and below (Subnormal)", + "subject": "180000001364000000000081EFAC855B416D2DEE04008000", + "string": "-0.100000000000000000000000000000000E-6143", + "match_string": "-1.00000000000000000000000000000000E-6144" + }, + { + "description": "[decq178] Nmin and below (Subnormal)", + "subject": "180000001364000000000081EFAC855B416D2DEE04008000", + "string": "-1.00000000000000000000000000000000E-6144" + }, + { + "description": "[decq179] Nmin and below (Subnormal)", + "subject": "180000001364000A00000000000000000000000000008000", + "string": "-0.000000000000000000000000000000010E-6143", + "match_string": "-1.0E-6175" + }, + { + "description": "[decq180] Nmin and below (Subnormal)", + "subject": "180000001364000A00000000000000000000000000008000", + "string": "-1.0E-6175" + }, + { + "description": "[decq181] Nmin and below (Subnormal)", + "subject": "180000001364000100000000000000000000000000028000", + "string": "-0.00000000000000000000000000000001E-6143", + "match_string": "-1E-6175" + }, + { + "description": "[decq182] Nmin and below (Subnormal)", + "subject": "180000001364000100000000000000000000000000028000", + "string": "-1E-6175" + }, + { + "description": "[decq183] Nmin and below (Subnormal)", + "subject": "180000001364000100000000000000000000000000008000", + "string": "-0.000000000000000000000000000000001E-6143", + "match_string": "-1E-6176" + }, + { + "description": "[decq184] Nmin and below (Subnormal)", + "subject": "180000001364000100000000000000000000000000008000", + "string": "-1E-6176" + }, + { + "description": "[decq190] underflow edge cases (Subnormal)", + "subject": "180000001364000100000000000000000000000000008000", + "string": "-1e-6176", + "match_string": "-1E-6176" + }, + { + "description": "[decq200] underflow edge cases (Subnormal)", + "subject": "18000000136400FFFFFFFF095BC138938D44C64D31008000", + "string": "-999999999999999999999999999999999e-6176", + "match_string": "-9.99999999999999999999999999999999E-6144" + }, + { + "description": "[decq400] zeros (Clamped)", + "subject": "180000001364000000000000000000000000000000000000", + "string": "0E-8000", + "match_string": "0E-6176" + }, + { + "description": "[decq401] zeros (Clamped)", + "subject": "180000001364000000000000000000000000000000000000", + "string": "0E-6177", + "match_string": "0E-6176" + }, + { + "description": "[decq414] clamped zeros... (Clamped)", + "subject": "180000001364000000000000000000000000000000FE5F00", + "string": "0E+6112", + "match_string": "0E+6111" + }, + { + "description": "[decq416] clamped zeros... (Clamped)", + "subject": "180000001364000000000000000000000000000000FE5F00", + "string": "0E+6144", + "match_string": "0E+6111" + }, + { + "description": "[decq418] clamped zeros... (Clamped)", + "subject": "180000001364000000000000000000000000000000FE5F00", + "string": "0E+8000", + "match_string": "0E+6111" + }, + { + "description": "[decq420] negative zeros (Clamped)", + "subject": "180000001364000000000000000000000000000000008000", + "string": "-0E-8000", + "match_string": "-0E-6176" + }, + { + "description": "[decq421] negative zeros (Clamped)", + "subject": "180000001364000000000000000000000000000000008000", + "string": "-0E-6177", + "match_string": "-0E-6176" + }, + { + "description": "[decq434] clamped zeros... (Clamped)", + "subject": "180000001364000000000000000000000000000000FEDF00", + "string": "-0E+6112", + "match_string": "-0E+6111" + }, + { + "description": "[decq436] clamped zeros... (Clamped)", + "subject": "180000001364000000000000000000000000000000FEDF00", + "string": "-0E+6144", + "match_string": "-0E+6111" + }, + { + "description": "[decq438] clamped zeros... (Clamped)", + "subject": "180000001364000000000000000000000000000000FEDF00", + "string": "-0E+8000", + "match_string": "-0E+6111" + }, + { + "description": "[decq601] fold-down full sequence (Clamped)", + "subject": "18000000136400000000000A5BC138938D44C64D31FE5F00", + "string": "1E+6144", + "match_string": "1.000000000000000000000000000000000E+6144" + }, + { + "description": "[decq603] fold-down full sequence (Clamped)", + "subject": "180000001364000000000081EFAC855B416D2DEE04FE5F00", + "string": "1E+6143", + "match_string": "1.00000000000000000000000000000000E+6143" + }, + { + "description": "[decq605] fold-down full sequence (Clamped)", + "subject": "1800000013640000000080264B91C02220BE377E00FE5F00", + "string": "1E+6142", + "match_string": "1.0000000000000000000000000000000E+6142" + }, + { + "description": "[decq607] fold-down full sequence (Clamped)", + "subject": "1800000013640000000040EAED7446D09C2C9F0C00FE5F00", + "string": "1E+6141", + "match_string": "1.000000000000000000000000000000E+6141" + }, + { + "description": "[decq609] fold-down full sequence (Clamped)", + "subject": "18000000136400000000A0CA17726DAE0F1E430100FE5F00", + "string": "1E+6140", + "match_string": "1.00000000000000000000000000000E+6140" + }, + { + "description": "[decq611] fold-down full sequence (Clamped)", + "subject": "18000000136400000000106102253E5ECE4F200000FE5F00", + "string": "1E+6139", + "match_string": "1.0000000000000000000000000000E+6139" + }, + { + "description": "[decq613] fold-down full sequence (Clamped)", + "subject": "18000000136400000000E83C80D09F3C2E3B030000FE5F00", + "string": "1E+6138", + "match_string": "1.000000000000000000000000000E+6138" + }, + { + "description": "[decq615] fold-down full sequence (Clamped)", + "subject": "18000000136400000000E4D20CC8DCD2B752000000FE5F00", + "string": "1E+6137", + "match_string": "1.00000000000000000000000000E+6137" + }, + { + "description": "[decq617] fold-down full sequence (Clamped)", + "subject": "180000001364000000004A48011416954508000000FE5F00", + "string": "1E+6136", + "match_string": "1.0000000000000000000000000E+6136" + }, + { + "description": "[decq619] fold-down full sequence (Clamped)", + "subject": "18000000136400000000A1EDCCCE1BC2D300000000FE5F00", + "string": "1E+6135", + "match_string": "1.000000000000000000000000E+6135" + }, + { + "description": "[decq621] fold-down full sequence (Clamped)", + "subject": "18000000136400000080F64AE1C7022D1500000000FE5F00", + "string": "1E+6134", + "match_string": "1.00000000000000000000000E+6134" + }, + { + "description": "[decq623] fold-down full sequence (Clamped)", + "subject": "18000000136400000040B2BAC9E0191E0200000000FE5F00", + "string": "1E+6133", + "match_string": "1.0000000000000000000000E+6133" + }, + { + "description": "[decq625] fold-down full sequence (Clamped)", + "subject": "180000001364000000A0DEC5ADC935360000000000FE5F00", + "string": "1E+6132", + "match_string": "1.000000000000000000000E+6132" + }, + { + "description": "[decq627] fold-down full sequence (Clamped)", + "subject": "18000000136400000010632D5EC76B050000000000FE5F00", + "string": "1E+6131", + "match_string": "1.00000000000000000000E+6131" + }, + { + "description": "[decq629] fold-down full sequence (Clamped)", + "subject": "180000001364000000E8890423C78A000000000000FE5F00", + "string": "1E+6130", + "match_string": "1.0000000000000000000E+6130" + }, + { + "description": "[decq631] fold-down full sequence (Clamped)", + "subject": "18000000136400000064A7B3B6E00D000000000000FE5F00", + "string": "1E+6129", + "match_string": "1.000000000000000000E+6129" + }, + { + "description": "[decq633] fold-down full sequence (Clamped)", + "subject": "1800000013640000008A5D78456301000000000000FE5F00", + "string": "1E+6128", + "match_string": "1.00000000000000000E+6128" + }, + { + "description": "[decq635] fold-down full sequence (Clamped)", + "subject": "180000001364000000C16FF2862300000000000000FE5F00", + "string": "1E+6127", + "match_string": "1.0000000000000000E+6127" + }, + { + "description": "[decq637] fold-down full sequence (Clamped)", + "subject": "180000001364000080C6A47E8D0300000000000000FE5F00", + "string": "1E+6126", + "match_string": "1.000000000000000E+6126" + }, + { + "description": "[decq639] fold-down full sequence (Clamped)", + "subject": "1800000013640000407A10F35A0000000000000000FE5F00", + "string": "1E+6125", + "match_string": "1.00000000000000E+6125" + }, + { + "description": "[decq641] fold-down full sequence (Clamped)", + "subject": "1800000013640000A0724E18090000000000000000FE5F00", + "string": "1E+6124", + "match_string": "1.0000000000000E+6124" + }, + { + "description": "[decq643] fold-down full sequence (Clamped)", + "subject": "180000001364000010A5D4E8000000000000000000FE5F00", + "string": "1E+6123", + "match_string": "1.000000000000E+6123" + }, + { + "description": "[decq645] fold-down full sequence (Clamped)", + "subject": "1800000013640000E8764817000000000000000000FE5F00", + "string": "1E+6122", + "match_string": "1.00000000000E+6122" + }, + { + "description": "[decq647] fold-down full sequence (Clamped)", + "subject": "1800000013640000E40B5402000000000000000000FE5F00", + "string": "1E+6121", + "match_string": "1.0000000000E+6121" + }, + { + "description": "[decq649] fold-down full sequence (Clamped)", + "subject": "1800000013640000CA9A3B00000000000000000000FE5F00", + "string": "1E+6120", + "match_string": "1.000000000E+6120" + }, + { + "description": "[decq651] fold-down full sequence (Clamped)", + "subject": "1800000013640000E1F50500000000000000000000FE5F00", + "string": "1E+6119", + "match_string": "1.00000000E+6119" + }, + { + "description": "[decq653] fold-down full sequence (Clamped)", + "subject": "180000001364008096980000000000000000000000FE5F00", + "string": "1E+6118", + "match_string": "1.0000000E+6118" + }, + { + "description": "[decq655] fold-down full sequence (Clamped)", + "subject": "1800000013640040420F0000000000000000000000FE5F00", + "string": "1E+6117", + "match_string": "1.000000E+6117" + }, + { + "description": "[decq657] fold-down full sequence (Clamped)", + "subject": "18000000136400A086010000000000000000000000FE5F00", + "string": "1E+6116", + "match_string": "1.00000E+6116" + }, + { + "description": "[decq659] fold-down full sequence (Clamped)", + "subject": "180000001364001027000000000000000000000000FE5F00", + "string": "1E+6115", + "match_string": "1.0000E+6115" + }, + { + "description": "[decq661] fold-down full sequence (Clamped)", + "subject": "18000000136400E803000000000000000000000000FE5F00", + "string": "1E+6114", + "match_string": "1.000E+6114" + }, + { + "description": "[decq663] fold-down full sequence (Clamped)", + "subject": "180000001364006400000000000000000000000000FE5F00", + "string": "1E+6113", + "match_string": "1.00E+6113" + }, + { + "description": "[decq665] fold-down full sequence (Clamped)", + "subject": "180000001364000A00000000000000000000000000FE5F00", + "string": "1E+6112", + "match_string": "1.0E+6112" + } + ] +} + diff --git a/test/decimal/decimal128-6.json b/test/decimal/decimal128-6.json new file mode 100644 index 000000000..5008fe581 --- /dev/null +++ b/test/decimal/decimal128-6.json @@ -0,0 +1,131 @@ +{ + "description": "Decimal128", + "bson_type": "0x13", + "test_key": "d", + "parseErrors": [ + { + "description": "Incomplete Exponent", + "subject": "1e" + }, + { + "description": "Exponent at the beginning", + "subject": "E01" + }, + { + "description": "Just a decimal place", + "subject": "." + }, + { + "description": "2 decimal places", + "subject": "..3" + }, + { + "description": "2 decimal places", + "subject": ".13.3" + }, + { + "description": "2 decimal places", + "subject": "1..3" + }, + { + "description": "2 decimal places", + "subject": "1.3.4" + }, + { + "description": "2 decimal places", + "subject": "1.34." + }, + { + "description": "Decimal with no digits", + "subject": ".e" + }, + { + "description": "2 signs", + "subject": "+-32.4" + }, + { + "description": "2 signs", + "subject": "-+32.4" + }, + { + "description": "2 negative signs", + "subject": "--32.4" + }, + { + "description": "2 negative signs", + "subject": "-32.-4" + }, + { + "description": "End in negative sign", + "subject": "32.0-" + }, + { + "description": "2 negative signs", + "subject": "32.4E--21" + }, + { + "description": "2 negative signs", + "subject": "32.4E-2-1" + }, + { + "description": "2 signs", + "subject": "32.4E+-21" + }, + { + "description": "Empty string", + "subject": "" + }, + { + "description": "leading white space positive number", + "subject": " 1" + }, + { + "description": "leading white space negative number", + "subject": " -1" + }, + { + "description": "trailing white space", + "subject": "1 " + }, + { + "description": "Invalid", + "subject": "E" + }, + { + "description": "Invalid", + "subject": "invalid" + }, + { + "description": "Invalid", + "subject": "i" + }, + { + "description": "Invalid", + "subject": "in" + }, + { + "description": "Invalid", + "subject": "-in" + }, + { + "description": "Invalid", + "subject": "Na" + }, + { + "description": "Invalid", + "subject": "-Na" + }, + { + "description": "Invalid", + "subject": "1.23abc" + }, + { + "description": "Invalid", + "subject": "1.23abcE+02" + }, + { + "description": "Invalid", + "subject": "1.23E+0aabs2" + } + ] +} diff --git a/test/decimal/decimal128-7.json b/test/decimal/decimal128-7.json new file mode 100644 index 000000000..85dcabbb0 --- /dev/null +++ b/test/decimal/decimal128-7.json @@ -0,0 +1,327 @@ +{ + "description": "Decimal128", + "bson_type": "0x13", + "test_key": "d", + "parseErrors": [ + { + "description": "[basx572] Near-specials (Conversion_syntax)", + "subject": "-9Inf" + }, + { + "description": "[basx516] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "-1-" + }, + { + "description": "[basx533] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "0000.." + }, + { + "description": "[basx534] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": ".0000." + }, + { + "description": "[basx535] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "00..00" + }, + { + "description": "[basx569] Near-specials (Conversion_syntax)", + "subject": "0Inf" + }, + { + "description": "[basx571] Near-specials (Conversion_syntax)", + "subject": "-0Inf" + }, + { + "description": "[basx575] Near-specials (Conversion_syntax)", + "subject": "0sNaN" + }, + { + "description": "[basx503] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "++1" + }, + { + "description": "[basx504] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "--1" + }, + { + "description": "[basx505] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "-+1" + }, + { + "description": "[basx506] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "+-1" + }, + { + "description": "[basx510] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": " +1" + }, + { + "description": "[basx513] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": " + 1" + }, + { + "description": "[basx514] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": " - 1" + }, + { + "description": "[basx501] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "." + }, + { + "description": "[basx502] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": ".." + }, + { + "description": "[basx519] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "" + }, + { + "description": "[basx525] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "e100" + }, + { + "description": "[basx549] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "e+1" + }, + { + "description": "[basx577] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": ".e+1" + }, + { + "description": "[basx578] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": "+.e+1" + }, + { + "description": "[basx581] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": "E+1" + }, + { + "description": "[basx582] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": ".E+1" + }, + { + "description": "[basx583] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": "+.E+1" + }, + { + "description": "[basx579] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": "-.e+" + }, + { + "description": "[basx580] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": "-.e" + }, + { + "description": "[basx584] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": "-.E+" + }, + { + "description": "[basx585] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": "-.E" + }, + { + "description": "[basx589] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": "+.Inf" + }, + { + "description": "[basx586] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": ".NaN" + }, + { + "description": "[basx587] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": "-.NaN" + }, + { + "description": "[basx545] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "ONE" + }, + { + "description": "[basx561] Near-specials (Conversion_syntax)", + "subject": "qNaN" + }, + { + "description": "[basx573] Near-specials (Conversion_syntax)", + "subject": "-sNa" + }, + { + "description": "[basx588] some baddies with dots and Es and dots and specials (Conversion_syntax)", + "subject": "+.sNaN" + }, + { + "description": "[basx544] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "ten" + }, + { + "description": "[basx527] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "u0b65" + }, + { + "description": "[basx526] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "u0e5a" + }, + { + "description": "[basx515] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "x" + }, + { + "description": "[basx574] Near-specials (Conversion_syntax)", + "subject": "xNaN" + }, + { + "description": "[basx530] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": ".123.5" + }, + { + "description": "[basx500] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1..2" + }, + { + "description": "[basx542] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1e1.0" + }, + { + "description": "[basx553] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1E+1.2.3" + }, + { + "description": "[basx543] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1e123e" + }, + { + "description": "[basx552] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1E+1.2" + }, + { + "description": "[basx546] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1e.1" + }, + { + "description": "[basx547] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1e1." + }, + { + "description": "[basx554] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1E++1" + }, + { + "description": "[basx555] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1E--1" + }, + { + "description": "[basx556] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1E+-1" + }, + { + "description": "[basx557] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1E-+1" + }, + { + "description": "[basx558] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1E'1" + }, + { + "description": "[basx559] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1E\"1" + }, + { + "description": "[basx520] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1e-" + }, + { + "description": "[basx560] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1E" + }, + { + "description": "[basx548] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1ee" + }, + { + "description": "[basx551] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1.2.1" + }, + { + "description": "[basx550] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1.23.4" + }, + { + "description": "[basx529] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "1.34.5" + }, + { + "description": "[basx531] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "01.35." + }, + { + "description": "[basx532] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "01.35-" + }, + { + "description": "[basx518] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "3+" + }, + { + "description": "[basx521] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "7e99999a" + }, + { + "description": "[basx570] Near-specials (Conversion_syntax)", + "subject": "9Inf" + }, + { + "description": "[basx512] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "12 " + }, + { + "description": "[basx517] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "12-" + }, + { + "description": "[basx507] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "12e" + }, + { + "description": "[basx508] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "12e++" + }, + { + "description": "[basx509] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "12f4" + }, + { + "description": "[basx536] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "111e*123" + }, + { + "description": "[basx537] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "111e123-" + }, + { + "description": "[basx540] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "111e1*23" + }, + { + "description": "[basx538] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "111e+12+" + }, + { + "description": "[basx539] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "111e1-3-" + }, + { + "description": "[basx541] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "111E1e+3" + }, + { + "description": "[basx528] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "123,65" + }, + { + "description": "[basx523] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "7e12356789012x" + }, + { + "description": "[basx522] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)", + "subject": "7e123567890x" + } + ] +} diff --git a/test/test_decimal128.py b/test/test_decimal128.py index d9d77daf3..4e5ef815a 100644 --- a/test/test_decimal128.py +++ b/test/test_decimal128.py @@ -15,18 +15,19 @@ """Tests for Decimal128.""" import codecs +import glob import json import os.path import pickle import sys from binascii import unhexlify -from decimal import Decimal +from decimal import Decimal, DecimalException sys.path[0:0] = [""] from bson import BSON -from bson.decimal128 import Decimal128 +from bson.decimal128 import Decimal128, create_decimal128_context from bson.json_util import dumps, loads from bson.py3compat import b from test import client_context, unittest @@ -68,28 +69,40 @@ class TestDecimal128(unittest.TestCase): self.assertEqual(str(dsnan), str(dsnan128.to_decimal())) self.assertEqual(str(dnsnan), str(dnsnan128.to_decimal())) + def test_decimal128_context(self): + ctx = create_decimal128_context() + self.assertEqual("NaN", str(ctx.copy().create_decimal(".13.1"))) + self.assertEqual("Infinity", str(ctx.copy().create_decimal("1E6145"))) + self.assertEqual("0E-6176", str(ctx.copy().create_decimal("1E-6177"))) + def test_spec(self): - path = os.path.join( - os.path.dirname(os.path.realpath(__file__)), - 'decimal', - 'decimal128.json') - with codecs.open(path, 'r', 'utf-8-sig') as fp: - suite = json.load(fp) + for path in glob.glob(os.path.join( + os.path.dirname(os.path.realpath(__file__)), + 'decimal', + 'decimal128*')): + with codecs.open(path, 'r', 'utf-8-sig') as fp: + suite = json.load(fp) - for test in suite['valid']: - subject = unhexlify(b(test['subject'])) - doc = BSON(subject).decode() - self.assertEqual(BSON.encode(doc), subject) + for test in suite.get('valid', []): + subject = unhexlify(b(test['subject'])) + doc = BSON(subject).decode() + self.assertEqual(BSON.encode(doc), subject) - self.assertEqual(str(doc['d']), test['string']) + if 'match_string' in test: + self.assertEqual( + str(Decimal128(test['string'])), test['match_string']) + else: + self.assertEqual(str(doc['d']), test['string']) - if test.get('from_extjson', True): - self.assertEqual(doc, loads(test['extjson'])) + if 'extjson' in test: + if test.get('from_extjson', True): + self.assertEqual(doc, loads(test['extjson'])) - if test.get('to_extjson', True): - extjson = test['extjson'].replace(' ', '') - self.assertEqual(extjson, dumps(doc).replace(' ', '')) + if test.get('to_extjson', True): + extjson = test['extjson'].replace(' ', '') + self.assertEqual(extjson, dumps(doc).replace(' ', '')) - for test in suite['parseErrors']: - self.assertRaises(ValueError, Decimal128, test['subject']) + for test in suite.get('parseErrors', []): + self.assertRaises( + DecimalException, Decimal128, test['subject'])