HNHacker News
TopNewBestAskShowJobs

marcandrysco

20 karma · joined March 27, 2015

submissionscomments
marcandrysco··on Show HN: Waputer – The WebAssembly Computer
Thank you for checking it out, and I am glad you are interested! You are right in that some bits are still needed to fully close the loop. The short of it: the idea is to write apps in Nako, compile it to WASM, and then publish it to run on Waputer.

The longer answer is that Waputer has a package system that Nako will soon take advantage of. NakoIDE itself is just a package that gets loaded when you go to the URL. The APIs for creating packages and allowing others to run them already exist; I have not had time to document them or integrate them directly into Nako. Users will be able to directly publish to URLs of the form "waputer.app/@user/package", while main applications like Nako exist just as "waputer.app/package". I will have a blog post that digs into the details of packages and publishing in a few weeks.

I also want to emphasize that I do not require everything end up on Waputer. The compiler that is running inside NakoIDE generates WASM files by default, but it can output x86_64 object files. I love interoperability.

marcandrysco··on How to Print Floating-Point Numbers Accurately (1990) [pdf]
We were able to update the paper on the ACM website: https://dl.acm.org/citation.cfm?id=2837654, although looking at it now, they did not update the title. I'll see if they can fix that.

There is very exciting news coming up with printing floating point. Ulf Adams from Google will be presenting a new algorithm called Ryu that appears to be super fast, simple, and perfectly accurate. Assuming the claims are correct, Ryu ought displace all of the current algorithms.

marcandrysco··on Printing Floating-Point Numbers: A Faster, Always Correct Method [pdf]
That really depends on what you are trying to get out of the algorithm. Using 64-bit integers, I don't think you can turn Grisu2 into an failure-free algorithm. However, you can definitely improve its reliability by handling special casing small integers (as is done in Errol2/Errol3). By my estimates, this should improve Grisu's success rate from ~99.5% to ~99.95% [see math at end]. The remaining 0.05% is far too large to for enumeration and using a lookup.

If you are willing to print numbers that are correct but possibly suboptimal, you can also use Errol2 and modify it to remove checking. This will give you the speed of Errol3 without having a lookup table. I might look at making such an implementation and maybe call it Errol2b.

[math for calculating approximate error rate] With an input floating-point format with p bits of precision and an intermediate format with q-bits of precision: the "chance" of value failing is close to 1 in 2^(q-p). With 2^p values per exponent, you're going to see about 2^(2p-q) errors per exponent. In the case if Grisu, q is 64 and p is 53, for a total of about 2^42 errors. These numbers only give rough estimates, you'd have to verify them manually.

marcandrysco··on Printing Floating-Point Numbers: A Faster, Always Correct Method [pdf]
Good catch! I mostly used __uint128_t out of haste. Ideally, I would like to remove dependencies on large integer types. For now, this remains future work.
marcandrysco··on Printing Floating-Point Numbers: A Faster, Always Correct Method [pdf]
This problem is even trickier than that. The core of the algorithm should be robust given different rounding modes, but the values in the lookup table may differ based on the rounding mode. While it may seem odd for the rounding mode to change at run-time, it has happened before: https://blogs.msdn.microsoft.com/oldnewthing/20080703-00/?p=....

I will have to look at this further. It might mean generating lookup table for every rounding mode and using their union. In general, changing the global state of the FPU seems to be a risky proposition.

marcandrysco··on Printing Floating-Point Numbers: A Faster, Always Correct Method [pdf]
It should be faster to replace the HP numbers entirely with 64-bit floats. Regardless, I think it would be a useful for two purposes: 1) it would serve as an implementation for chips with only 32-bit floats (maybe some kinds of embedded systems) and 2) we can exhaustively test and verify that the algorithm works on all 32-bit numbers, providing more confidence in the 64-bit version.
marcandrysco··on Printing Floating-Point Numbers: A Faster, Always Correct Method [pdf]
Author here. We intend for the GitHub repo (https://github.com/marcandrysco/Errol) to be the primary source for Errol. We still want to add a few improvements to the existing implementation: selecting the middle-most shortest number and an implementation for 32-bit floats (and maybe __float128).
marcandrysco··on Printing Floating-Point Numbers: A Faster, Always Correct Method [pdf]
Author here. The simplest way to describe those 42 values: the value we want to output (the shortest value) is very close to the midpoint between two floating-point values. Since the best answer so close to a midpoint, its difficult for the algorithm to decide which direction that number will round.

So, how can we make sure that such numbers are converted correctly? The answer from Steel & White's paper is to perform arbitrary integer arithmetic and leave nothing up to chance. The Grisu3 algorithm by Loitsch showed that 64-bits correct converts about 99.5% of numbers. As you increase the amount of precision, you can improve your accuracy, but there is no guarantee that even 128-bits or 256-bits is enough to correctly convert all numbers.

Instead of trying to be 100% correct, our algorithm sidesteps the issue entirely by enumerating all failures a priori.