[Glass] Faster Float printing possible?

Mariano Martinez Peck via Glass glass at lists.gemtalksystems.com
Wed Feb 8 12:50:01 PST 2017


On Wed, Feb 8, 2017 at 5:41 PM, Martin McClure <
martin.mcclure at gemtalksystems.com> wrote:

> On 02/08/2017 11:59 AM, Mariano Martinez Peck via Glass wrote:
>
> On Wed, Feb 8, 2017 at 3:31 PM, Dale Henrichs via Glass <
> glass at lists.gemtalksystems.com> wrote:
>
>> Mariano,
>>
>> Float>>asString is implemented as a primitive and you could probably use
>> that call just about anywhere you want ... I am not a floating point guy,
>>
>
> Where is Martin when we need him?? hahahahahhaa
>
>
>> so I cannot comment on where you will see differences in the output
>> strings (if any at all) and of course I don't know how important precision
>> is when you are passing around json ...
>>
>
> Thanks Dale. That indeed gives me like .. around 2x performance
> improvement. As for the results, for JSON it looks like correct. But I
> would love to hear if Martin has something else to comment on.
>
> Hi Mariano,
>
>
Here he is!


> I guess I have something of a reputation. :-)
>

hahahaahha you bet.


> Printing binary floats in decimal is a surprisingly complex topic, with
> quite a few papers published on the topic.
>
> I haven't looked at your case in detail (especially the JSON conversion)
> but IIRC the Float>>asString primitive uses a double printing routine in
> libc, which should be both fast and accurate. Though there *was* for
> several years a bug in glibc that made it print an insufficient number of
> digits for a small percentage of floats, so that when read back in the
> resulting float was one LSB off from the original float. That was fixed in
> glibc several years ago, so recent Linux distributions should do correct
> printing now.
>
>
>
OK great. So.... I guess the double printing feature is the one used by
`printf` ? Because Float >> #asString comment say:

* The receiver is printed using the C printf format string '%.16g'  .*


Else you  may be talking of another method?


Thanks!

-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20170208/cc2f950a/attachment.html>


More information about the Glass mailing list