4 ms·
Honestly. The code is fine. This is for presenting stuff in a user interface. Who cares if you can find some weird edge case using MAX_LONG and MAX_DOUBLE whic
by throwaway4good 5y ago
Honestly. The code is fine.
This is for presenting stuff in a user interface. Who cares if you can find some weird edge case using MAX_LONG and MAX_DOUBLE which never will occur in practice.
- Cthulhu_ 5y agoUntil it does.
- throwaway4good 5y agoReadability and maintainability matters far more. And no - the edge cannot occur as it would require a file / whatever to have that size.
- throwaway4good 5y agoFor example - what is the meaning of the parameter "si"? I betcha that is going to give you more bugs than the edge cases discussed here.
- ayewo 5y agoThe parameter "si" here stands for International System of Units, or SI for short [0]. 0: https://en.wikipedia.org/wiki/International_System_of_Units#SI_metric_prefixes_and_the_decimal_nature_of_the_SI_system https://en.wikipedia.org/wiki/International_System_of_Units#...
- moring 5y agoThe original doesn't have types, but the modified version of humanReadableByteCount() uses a "long bytes" and as such will fail if the file size is (Long.MAX_VALUE+1) because it cannot even accept the correct size as its argument in the first place. Implementing these edge cases makes adds one more working case to 2^63 (2^64 if negative file sizes are valid) when the bigger problem is using the type "long" when files of that size are possible on the target system.