We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 433a764 commit 2a83c8fCopy full SHA for 2a83c8f
lib/encode.ex
@@ -127,9 +127,23 @@ defmodule Jason.Encode do
127
Integer.to_string(integer)
128
end
129
130
+ has_short_format = try do
131
+ :erlang.float_to_binary(1.0, [:short])
132
+ catch
133
+ _, _ -> false
134
+ else
135
+ _ -> true
136
+ end
137
+
138
@spec float(float) :: iodata
- def float(float) do
- :io_lib_format.fwrite_g(float)
139
+ if has_short_format do
140
+ def float(float) do
141
+ :erlang.float_to_binary(float, [:short])
142
143
144
145
+ :io_lib_format.fwrite_g(float)
146
147
148
149
@spec list(list, opts) :: iodata
0 commit comments