Live data from Hacker News

Ryū: Fast Float-To-String Conversion

pldi18.sigplan.org

21–30 of 45 posts

Re: Ryū: Fast Float-To-String Conversion

#21

Earlier quoted context omitted.

Real-time displays often need to show floating point numbers as they change. As a simple example, the time remaining display of a music player ticks down as the music plays. Now in this case, it is easy to fake it by using integers and then placing the decimal point, but if you were controlling something complex in real time you might not be able to do this as easily.

> it is easy to fake it by using integers and then placing the decimal point That's not "faking it", that using fixed point numbers [1]. They are a great alternative if the numbers stay in roughly the same magnitude, and are much saner when dealing with e.g. money. 1: https://en.wikipedia.org/wiki/Fixed-point_arithmetic

Good point, and thanks. But if you are doing a real-time display (like an industrial controller, for example), you may not be able to choose a fixed point number as your source. I chose the music time example first because it is a common use of a number that needs to change in (almost) real time.

Re: Ryū: Fast Float-To-String Conversion

#26
post #7

(De-)Serialization being such a common task both in Servers and clients nowadays I wonder if special instructions would make sense in CPUs

At that point just base-64 for your IEEE floats.... Because anywhere where you need that speed you can better handle it without using strings...

Re: Ryū: Fast Float-To-String Conversion

#27
post #16
post #14

Earlier quoted context omitted.

Often, numbers in JS happen to be just integers. Would the implementation optimize for that case?

Javascript JITs specialize for integers already. I don't know if Ryū does specifically though.

It doesn't optimize for ints right now. I thought about that, but haven't tried it yet.

Re: Ryū: Fast Float-To-String Conversion

#29
post #18

This is in a track called "PLDI Research Papers - Floats and Maps". Is that because they had one paper on maps and two on floats, and decided to put them together, or is there some deep connection between the two?

As far as I could tell, there wasn't any deep connection between the talks.

Re: Ryū: Fast Float-To-String Conversion

#30
post #26
post #7

(De-)Serialization being such a common task both in Servers and clients nowadays I wonder if special instructions would make sense in CPUs

At that point just base-64 for your IEEE floats.... Because anywhere where you need that speed you can better handle it without using strings...

But that's not necessarily interoperable. E.g., some JSON parsers might produce IEEE754 doubles, but others might use arbitrary precision representations -- what then? One answer is to make JSON support only IEEE754 doubles, but it's a bit late for that, so at most one can recommend that implementors stick to IEEE754.

If you are starting from scratch, and want to support only platforms that support IEEE754 in hardware, and so on, then yes, just serialize the raw bits.

Post reply on HN