[squeak-dev] The Trunk: System-bf.488.mcz
nicolas.cellier.aka.nice at gmail.com
Tue Jul 10 10:48:21 UTC 2012
2012/7/9 Bert Freudenberg <bert at freudenbergs.de>:
> On 2012-07-09, at 22:18, Nicolas Cellier wrote:
>> 2012/7/9 Bert Freudenberg <bert at freudenbergs.de>:
>>> On 2012-07-09, at 17:57, Chris Muller wrote:
>>>> Beat me to it but you forgot to update the sends to
>>>> #asStringWithCommasSigned. It was deprecated because this is the only
>>>> sender and it's an exceptional case to want to print "+" in front. We
>>>> should use #asStringWithCommasSigned: true.
>>> Feel free to improve :)
>>> Another idea would be to tweak roundTo: so the result would print as expected. Any floating point magician out there? ;)
>>> - Bert -
>> This would be something like:
>> roundToDecimalPlaces: d
>> ^(self asTrueFraction roundTo: (1/10 raisedTo: d)) asFloat
>> slightly different from Pharo initial proposition
>> round: d
>> ^((self * (10 raisedTo: d)) rounded / (10 raisedTo: d)) asFloat
>> For example, with receiver 0.995, we have 0.995 < (995/1000) so the former is
>> (0.995 roundToDecimalPlaces: d) -> 0.99
>> while the later is
>> (0.995 round: 2) -> 1.0
> Ah, I remember that discussion now. That Pharo version is 10x more efficient than the one using asTrueFraction, though. I'd be happy with that I guess.
>> REMINDER: I started http://ss3.gemstone.com/ss/NumberPrinter to factor
>> a few Float printing methods
>> However, my initial solution is not very flexible because it relies
>> too much on inheritance.
>> It's already a progress compared to explosion of duplications in current trunk.
> Feature request: allow to print with thousands grouping, i.e. a space between every 3 digits :)
> - Bert -
Sure, that's typically the limitation with this mixture of
parametrization and inheritance (used only for main format parameter).
We can add such a feature with a new parameter, but will have to
modify the existing classes & algorithms...
It's not easily extensible (by third party optional modules).
More information about the Squeak-dev