After finding out the cause of the bug I found in jruby, I said to myself — “This should be quite easy to fix!”. So I checked out the jruby sources, found RubyFloat.java file and started editing it. First I found something called DecimalFormat, which after googling appeared to be just what I needed — the class used to format number to strings! The problem was it had a definition I didn’t expect. I was waiting for something like the good old “#.15g” used in the MRI code, but with a precision of 16, perhaps. And what I found was ”##############0.0##############”. Well, I figured out how it worked and removed some of the #s. But nothing changed. I dug deeper and found out that this formatter was used only for Floats with “E”. I rewrote the code to pass all floats through it. It helped, kinda. But it didn’t do quite what I wanted. I wanted it to behave like “#.15g”, and it didnt. It worked for my 10.1*3 case, but it removed some precision in other cases where it should not.
I then tried to find a way to literally use “%15g” (I was naive enough to hope there was one). The closest thing out there was the 1.5.0-only Formatter class. But it just didn’t work for me. By the way, are there any other errors in java except “cannot find symbol”? Anyway, I made a simple helloworldish app just to test if it worked at all. I sure did work, but it’s behaviour was so distant from the C one that I decided not to bother making it work in the main app, it was useless anyway. So after multiple hours with java I’m at my starting point — wanting to make it output float numbers like C’s sprintf(”%#.15g”,f) does, but seeing no real way to do it, alas.
Good night, Seattle: we love you!