[squeak-dev] The Trunk: System-bf.488.mcz
Bert Freudenberg
bert at freudenbergs.de
Mon Jul 9 21:36:13 UTC 2012
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
> http://code.google.com/p/pharo/issues/detail?id=5590
> 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.
>
> Nicolas
Feature request: allow to print with thousands grouping, i.e. a space between every 3 digits :)
- Bert -
More information about the Squeak-dev
mailing list
|