Date: Wed, 09 Apr 2014 08:02:32 +0100
From: Jeff Allen <email@example.com>
Subject: Re: [Jython-dev] Test failures for float
To: Jython Developers <firstname.lastname@example.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
I wrote a pretty good replacement for core.stringlib.Formatter, based on
java.text.DecimalFormatter. It agrees with CPython for all "reasonable"
precisions, that is to say up to 16 significant figures, and no-one has
had to take the log of anything. It can provide float.__str__ and
float.__repr__ more cleanly than at present too.
But it fails tests like this: AssertionError:
I haven't come across any cases where the problem is that the actual
float value is different (considered at the bit-level using
float.hex()); it's all on the output formatting. CPython appears to give
us the exact value -- there is always a finite answer, though it may
have a thousand digits. DecimalFormatter, which is at bottom just
Double.toString(), gives us just enough digits to differ from the next
float bit pattern.
Experiments with BigDecimal suggest I can get exact conformance by that
route and it seems worth the attempt, so I'm going that way.