You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alexis Bataille (Commented) (JIRA)" <ji...@apache.org> on 2011/10/10 15:29:29 UTC
[jira] [Commented] (IO-226) question with
byteCountToDisplaySize(long size)
[ https://issues.apache.org/jira/browse/IO-226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13124094#comment-13124094 ]
Alexis Bataille commented on IO-226:
------------------------------------
+1
Indeed I re-implements this method with :
{code}
String displaySize;
if ( size / FileUtils.ONE_GB > 0 )
{
displaySize = String.valueOf( new BigDecimal( size ).divide( BD_ONE_GO, BigDecimal.ROUND_CEILING ) )
+ " GO";
}
else if ( size / FileUtils.ONE_MB > 0 )
{
displaySize = String.valueOf( new BigDecimal( size ).divide( BD_ONE_MO, BigDecimal.ROUND_CEILING ) )
+ " MO";
}
else if ( size / FileUtils.ONE_KB > 0 )
{
displaySize = String.valueOf( new BigDecimal( size ).divide( BD_ONE_KO, BigDecimal.ROUND_CEILING ) )
+ " KO";
}
else
{
displaySize = String.valueOf( size ) + " octets";
}
return displaySize;
{code}
> question with byteCountToDisplaySize(long size)
> -----------------------------------------------
>
> Key: IO-226
> URL: https://issues.apache.org/jira/browse/IO-226
> Project: Commons IO
> Issue Type: Improvement
> Components: Utilities
> Reporter: shu kai yuan
> Fix For: 2.0
>
>
> I do not understand the byteCountToDisplaySize(long size) method which is in class FileUtils of the package org.apache.commons.io.
> If the parameter size is 2047 , the method will return 1 KB.Why it will lose precision.
> I read the code.
> Maybe it is a bug?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira