Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ Knut Wannheden (@knutwannheden)
* Contributed #518: Should not read past end for CBOR string values
(2.18.1)

Steven Fackler (@sfackler)
* Reported #300: (smile) Floats are encoded with sign extension while
doubles without
(2.19.0)

Idan Sheinberg (@sheinbergon)
* Reported #308: (avro) Incorrect serialization for `LogicalType.Decimal` (Java
`BigDecimal`)
Expand Down
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Active maintainers:

2.19.0 (not yet released)

#300: (smile) Floats are encoded with sign extension while doubles without
(reported by Steven F)
#308: (avro) Incorrect serialization for `LogicalType.Decimal` (Java `BigDecimal`)
(reported by Idan S)
(fix contributed by Michal F)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1726,13 +1726,13 @@ public void writeNumber(float f) throws IOException
int i = Float.floatToRawIntBits(f);
_outputBuffer[_outputTail++] = TOKEN_BYTE_FLOAT_32;
_outputBuffer[_outputTail+4] = (byte) (i & 0x7F);
i >>= 7;
i >>>= 7;
_outputBuffer[_outputTail+3] = (byte) (i & 0x7F);
i >>= 7;
i >>>= 7;
_outputBuffer[_outputTail+2] = (byte) (i & 0x7F);
i >>= 7;
i >>>= 7;
_outputBuffer[_outputTail+1] = (byte) (i & 0x7F);
i >>= 7;
i >>>= 7;
_outputBuffer[_outputTail] = (byte) (i & 0x7F);
_outputTail += 5;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.fasterxml.jackson.dataformat.smile.gen;

import java.io.ByteArrayOutputStream;
import java.util.Arrays;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.dataformat.smile.*;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class SmileGeneratorNumbersTest
Expand Down Expand Up @@ -146,7 +148,12 @@ public void testFloatUnusedBits() throws Exception
byte[] encoded = out.toByteArray();
assertEquals(6, encoded.length);
assertEquals(0x28, encoded[0]); // type byte, float
}

// From 0x80 0x00 0x00 0x00 (spread over 5 x 7bits)
assertArrayEquals(new byte[] {
0x08, 0x00, 0x00, 0x00, 0x00
}, Arrays.copyOfRange(encoded, 1, encoded.length));
}

// [dataformats-binary#300]
@Test
Expand All @@ -159,6 +166,12 @@ public void testDoubleUnusedBits() throws Exception
byte[] encoded = out.toByteArray();
assertEquals(11, encoded.length);
assertEquals(0x29, encoded[0]); // type byte, double
// From 0x80 0x00 0x00 0x00 ... 0x00 (spread over 10 x 7 bits)

assertArrayEquals(new byte[] {
0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00
}, Arrays.copyOfRange(encoded, 1, encoded.length));
}

// #16: Problems with 'Stringified' numbers
Expand Down