Skip to content

Commit ff99e31

Browse files
committed
Fix serialising IEEE 754-2008 decimals
1 parent b1a052e commit ff99e31

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

deps/amqp10_common/src/amqp10_binary_generator.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ generate1({array, Type, List}) ->
177177
[16#e0, S + 1, Count, Array]
178178
end;
179179

180-
generate1({as_is, TypeCode, Bin}) ->
181-
<<TypeCode, Bin>>.
180+
generate1({as_is, TypeCode, Bin}) when is_binary(Bin) ->
181+
[TypeCode, Bin].
182182

183183
constructor(symbol) -> 16#b3;
184184
constructor(ubyte) -> 16#50;

deps/amqp10_common/test/binary_generator_SUITE.erl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ numerals(_Config) ->
105105
roundtrip({double, 0.0}),
106106
roundtrip({double, 1.0}),
107107
roundtrip({double, -1.0}),
108+
%% decimal32
109+
roundtrip({as_is, 16#74, binary:copy(<<0>>, 4)}),
110+
%% decimal64
111+
roundtrip({as_is, 16#84, binary:copy(<<0>>, 8)}),
112+
%% decimal128
113+
roundtrip({as_is, 16#94, binary:copy(<<0>>, 16)}),
108114
ok.
109115

110116
utf8(_Config) ->

0 commit comments

Comments
 (0)