Files sizes are displayed wrongly: omiting digits instead of rounding values

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
ackuxacky
Junior Member
Junior Member
Posts: 43
Joined: 2012-09-28, 06:17 UTC

Files sizes are displayed wrongly: omiting digits instead of rounding values

Post by *ackuxacky »

There is a rounding error when displaying file sizes. The engine omits digits instead of rounding values.

Two text files were created:
  • test size 1023bytes.txt
  • test size 1024bytes.txt
One is exactly 1kB (1024B) large and the other is (1kB - 1B = 1023B) large. Mathematically their size should be displayed as follows:
  • test size 1023bytes.txt: 1023B = 0.99902kB = 0.999kB = 1.00kB = 1.0kB
  • test size 1024bytes.txt: 1024B = 1.00000kB = 1.00kB = 1.0kB
But instead, the size of the smaller file is displayed:
  • test size 1023bytes.txt: 1023B = 0.99kB = 0.9kB
Not the difference between the green expected and red displayed value.

See screenshots:
  • test size 1023bytes.png
  • test size 1024bytes.png
  • test both files in x.xx notation.png
https://www.mediafire.com/folder/9wj6jsv9slmo8/test_file_size_TC_display
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Files sizes are displayed wrongly: omiting digits instead of rounding values

Post by *ghisler(Author) »

It's just a question of conventions whether you round up, round down, or do something in between. What TC uses is the "floor" method. There are actually a lot of rounding methods, see for example:
https://www.mathsisfun.com/numbers/rounding-methods.html
Author of Total Commander
https://www.ghisler.com
ackuxacky
Junior Member
Junior Member
Posts: 43
Joined: 2012-09-28, 06:17 UTC

Re: Files sizes are displayed wrongly: omiting digits instead of rounding values

Post by *ackuxacky »

Thank you for the link and article. The article gives a good overview of the rounding methods, but ommits the usage cases or the reason to use either of them. (Some of them seem to be correcting methods for loosing information when dropping digits, e.g., the banker rounding, and have some valid background: with many values at even distribution the sum of the rounded values is changing the least.) But using 'floor' or 'ceiling' shows the most of the invalid values the most of the times.

I believe that the convention of rounding shall not be broken. The 3rd grader is tough about rounding 1.5 to 2 and rounding 1.4 to 1.

What does it bring to TC to use a different rounding than what the average user expects? Is using floor any solution for some other user issues?
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Files sizes are displayed wrongly: omiting digits instead of rounding values

Post by *Usher »

For me it would be more safe to use ceiling rounding for file size and floor rounding for free space.
Andrzej P. Wozniak
Polish subforum moderator
Post Reply