Skip to content

Commit

Permalink
Fixed #707 for 2.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 16, 2015
1 parent 4bfff9d commit eedaeb8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
15 changes: 10 additions & 5 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
Project: jackson-databind
Version: 2.3.5 (13-Jan-2014)
Version: 2.3.6 (not yet released)

#496: Wrong result for TextNode("false").asBoolean(true)
(reported by Ivar R, ivarru@github)
#543: Problems resolving self-referential generic types.
#656: defaultImpl configuration is ignored for WRAPPER_OBJECT
#707: Error in getting string representation of an ObjectNode with a float number value
(reported by @navidqar)

------------------------------------------------------------------------
=== History: ===
------------------------------------------------------------------------

2.3.5 (13-Jan-2014)

#496: Wrong result for TextNode("false").asBoolean(true)
(reported by Ivar R, ivarru@github)
#543: Problems resolving self-referential generic types.
#656: defaultImpl configuration is ignored for WRAPPER_OBJECT

2.3.4 (17-Jul-2014)

#459: BeanDeserializerBuilder copy constructor not copying `_injectables`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ public BigInteger bigIntegerValue() {

@Override
public String asText() {
return NumberOutput.toString(_value);
// As per [jackson-core#179]
// return NumberOutput.toString(_value);
return Float.toString(_value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,25 @@ public void testDouble() throws Exception
// @since 2.2
public void testFloat()
{
FloatNode n = FloatNode.valueOf(0.25f);
FloatNode n = FloatNode.valueOf(0.45f);
assertStandardEquals(n);
assertTrue(0 != n.hashCode());
assertEquals(JsonToken.VALUE_NUMBER_FLOAT, n.asToken());
assertEquals(JsonParser.NumberType.FLOAT, n.numberType());
assertEquals(0, n.intValue());
assertEquals(0.25, n.doubleValue());
assertEquals(0.25f, n.floatValue());

// NOTE: conversion to double NOT as simple as with exact numbers like 0.25:
assertEquals(0.45f, n.floatValue());
assertEquals("0.45", n.asText());

// so; as double we'll get more complex number; however, should round-trip
// to something that gets printed the same way. But not exact value, alas, hence:
assertEquals("0.45", String.valueOf((float) n.doubleValue()));

assertNotNull(n.decimalValue());
// possibly surprisingly, however, this will produce same output:
assertEquals(BigInteger.ZERO, n.bigIntegerValue());
assertEquals("0.25", n.asText());
assertEquals("0.45", n.asText());

// 1.6:
assertNodeNumbers(FloatNode.valueOf(4.5f), 4, 4.5f);
Expand Down

0 comments on commit eedaeb8

Please sign in to comment.