Bug 16649 - format.object_size(): Add support for IEC units KiB, MiB, GiB, ...
Summary: format.object_size(): Add support for IEC units KiB, MiB, GiB, ...
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: R-devel (trunk)
Hardware: All All
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-12-30 21:49 UTC by Henrik Bengtsson
Modified: 2016-01-05 14:49 UTC (History)
1 user (show)

See Also:


Attachments
Patch for R/object.size.R and man/object.size.Rd (2.70 KB, patch)
2015-12-30 21:49 UTC, Henrik Bengtsson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Henrik Bengtsson 2015-12-30 21:49:28 UTC
Created attachment 1960 [details]
Patch for R/object.size.R and man/object.size.Rd

Please consider adding support for the IEC standard for _binary_ byte size units, e.g. KiB, MiB, GiB, ...

I've attached a patch for utils/R/object.size.R and utils/man/object.size.Rd adding support for KiB, ..., YiB.  Example of output:

> format(structure(1e6, class = "object_size"), units="KiB")
[1] "976.6 KiB"
> format(structure(1e6, class = "object_size"), units="MiB")
[1] "1 MiB"
> format(structure(1e7, class = "object_size"), units="MiB")
[1] "9.5 MiB"
> format(structure(1e13, class = "object_size"), units="TiB")
[1] "9.1 TiB"
> format(structure(1e25, class = "object_size"), units="YiB")
[1] "8.3 YiB"

The patch is backward compatible, so it should not break anything.  I've scanned the R source code for usages of "Kb", "Mb", "Gb", "KB", "MB" and "GB" to find if similar support needs to be added elsewhere, but I could not find any other occurrence.

Thank you

Henrik
Comment 1 Martin Maechler 2016-01-05 14:49:35 UTC
Thanks a a lot, Henrik.   I've committed (an extension) of your patch,
as svn rev 69869