[ https://issues.apache.org/jira/browse/IO-876?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Samael Bate updated IO-876: --------------------------- Affects Version/s: 2.20.0 > FileUtils.byteCountToDisplaySize returns incorrect values > --------------------------------------------------------- > > Key: IO-876 > URL: https://issues.apache.org/jira/browse/IO-876 > Project: Commons IO > Issue Type: Bug > Affects Versions: 2.8.0, 2.20.0 > Reporter: Samael Bate > Priority: Major > > I get that there can be discrepancies depending on whether discussing GB or > GiB but as commons-io has a constant for {{FileUtils.ONE_GB}} which is > 1,073,741,824 I can presume that the value being returned by > FileUtils.byteCountToDisplaySize should actually be an accurate GiB value, > despite the text being just GB. > So there's two problems here, the text saying MG, GB, etc should probably be > formatted with the more correct text post-fixed (MiB, GiB, etc). > However my main issue is that either way the results are just wrong. This > seems to be caused by the function simply dropping the fractional digits > rather than using any decimal places or rounding. > For example 1.9 GB will get returned by this function as "1 GB": > {code:java} > FileUtils.byteCountToDisplaySize(2018148352L) // returns "1 GB" but is only > just a little short of 2 GB{code} -- This message was sent by Atlassian Jira (v8.20.10#820010)