vscode_erlang icon indicating copy to clipboard operation
vscode_erlang copied to clipboard

Float literals are replaced with approximation

Open dpavsrtrl opened this issue 5 years ago • 4 comments

3.3 becomes 3.2999999999999998 3.4 becomes 3.3999999999999999

Is there a way to disable this?

dpavsrtrl avatar Mar 14 '19 16:03 dpavsrtrl

Hi,

Thanks for your report could you shared logs ? you can activate it in settings (set erlang.verbose to true)

pgourlain avatar Mar 17 '19 16:03 pgourlain

https://gist.github.com/dpavsrtrl/b4c4ff3780ebfdcc9920230dbfc1efc6

dpavsrtrl avatar Mar 18 '19 15:03 dpavsrtrl

Hi @dpavsrtrl,

I found the origin of this issue : B = 3.1 + 3.2 + 3.3 + 3.4 + 3.5 + 3.6 + 3.7 + 3.8 + 3.9.

after formating document it becomes : B = 3.1 + 3.2 + 3.29999999999999982236 + 3.39999999999999991118 + 3.5 + 3.6 + 3.7 + 3.79999999999999982236 + 3.89999999999999991118.

I use erlang to format document (erl_tidy). Then, I would like to use 'erl_prettypr:format', but there is the same issue... after digging, it come from 'erl_syntax:float_literal({float, 7, 3.4}), which use float_to_list() that returns '3.39999999999999991118e+00', So, unfortunately I didn't found a quick workaround for this problem.

pgourlain avatar Mar 31 '19 10:03 pgourlain

Fixed by #224

wojteksurowka avatar Jan 02 '22 14:01 wojteksurowka