[erlang-questions] new float_to_list/2 BIF - critique wanted

Gleb Peregud gleber.p@REDACTED
Sun May 3 15:18:34 CEST 2009


I've been struggling with the very low performance of erlang term to
JSON conversion with mochijson. It turned out that mochinums:digits/1
is very slow. So I've tried using io_lib:format/2 and it turned to be
still not satisfying. Then I've tried the float_to_list/1 BIF, but it
always produced 23-char long list, while I need only ~9 digits. So
I've implemented BIF float_to_list/2,  which accepts additional
parameter Precision. Tested only on Linux. Win32 and vxworks code is

Patch is attached. Critique is very welcomed! If the patch is valuable
I'll send it to the erlang-patches mailing list

Best regards,
Gleb Peregud

Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong
-------------- next part --------------
A non-text attachment was scrubbed...
Name: float_to_list_2.patch
Type: text/x-diff
Size: 5162 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090503/75370790/attachment.bin>

More information about the erlang-questions mailing list