File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed
main/java/org/msgpack/jackson/dataformat
test/java/org/msgpack/jackson/dataformat Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -270,7 +270,8 @@ private void packBigDecimal(BigDecimal decimal)
270270 if (failedToPackAsBI ) {
271271 double doubleValue = decimal .doubleValue ();
272272 //Check to make sure this BigDecimal can be represented as a double
273- if (!decimal .stripTrailingZeros ().toEngineeringString ().equals (BigDecimal .valueOf (doubleValue ).toEngineeringString ())) {
273+ if (!decimal .stripTrailingZeros ().toEngineeringString ().equals (
274+ BigDecimal .valueOf (doubleValue ).stripTrailingZeros ().toEngineeringString ())) {
274275 throw new IllegalArgumentException ("MessagePack cannot serialize a BigDecimal that can't be represented as double. " + decimal );
275276 }
276277 messagePacker .packDouble (doubleValue );
Original file line number Diff line number Diff line change @@ -304,10 +304,12 @@ public void testBigDecimal()
304304 double d0 = 1.23456789 ;
305305 double d1 = 1.23450000000000000000006789 ;
306306 String d2 = "12.30" ;
307+ String d3 = "0.00001" ;
307308 List <BigDecimal > bigDecimals = Arrays .asList (
308309 BigDecimal .valueOf (d0 ),
309310 BigDecimal .valueOf (d1 ),
310311 new BigDecimal (d2 ),
312+ new BigDecimal (d3 ),
311313 BigDecimal .valueOf (Double .MIN_VALUE ),
312314 BigDecimal .valueOf (Double .MAX_VALUE ),
313315 BigDecimal .valueOf (Double .MIN_NORMAL )
@@ -320,6 +322,7 @@ public void testBigDecimal()
320322 assertEquals (d0 , unpacker .unpackDouble (), 0.000000000000001 );
321323 assertEquals (d1 , unpacker .unpackDouble (), 0.000000000000001 );
322324 assertEquals (Double .valueOf (d2 ), unpacker .unpackDouble (), 0.000000000000001 );
325+ assertEquals (Double .valueOf (d3 ), unpacker .unpackDouble (), 0.000000000000001 );
323326 assertEquals (Double .MIN_VALUE , unpacker .unpackDouble (), 0.000000000000001 );
324327 assertEquals (Double .MAX_VALUE , unpacker .unpackDouble (), 0.000000000000001 );
325328 assertEquals (Double .MIN_NORMAL , unpacker .unpackDouble (), 0.000000000000001 );
You can’t perform that action at this time.
0 commit comments