> On 10 Nov 2016, at 10:25, Sven Van Caekenberghe <[email protected]> wrote:
> 
> 
>> On 10 Nov 2016, at 10:10, Denis Kudriashov <[email protected]> wrote:
>> 
>> 
>> 2016-11-09 23:30 GMT+01:00 Nicolas Cellier 
>> <[email protected]>:
>> uptime                  0h0m0s
>> memory                  70,918,144 bytes
>>        old                     61,966,112 bytes (87.4%)
>>        young           2,781,608 bytes (3.9000000000000004%)
>> I see yet another bad usage of round:/roundTo: --------------^
>> 
>> It just printed float :). I think anybody round values in this statistics.
> 
> Nothing should be rounded. Just compute the percentage and then use 
> #printShowingDecimalPlaces: or #printOn:showingDecimalPlaces:

For example,

'Status OK - Clock {1} - Allocated {2} bytes - {3} % free.' format: { 
   DateAndTime now.
   self memoryTotal asStringWithCommas. 
   (self memoryFree / self memoryTotal * 100.0) printShowingDecimalPlaces: 2 }

Prints

Status OK - Clock 2016-11-10T09:47:18.367242+00:00 - Allocated 217,852,528 
bytes - 2.36 % free.

(This is part of NeoConsole, a REPL package).


Reply via email to