Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1125899906842620 bytes gives the result of 1024 TB because of rounding #103

Closed
ulitiy opened this issue Sep 19, 2019 · 7 comments
Closed
Assignees
Labels

Comments

@ulitiy
Copy link

ulitiy commented Sep 19, 2019

I see the only way of solving it – very inelegant corner case management.

        let res = parseFloat((bytes / (1024 ** pow)).toFixed(precision));
        if (res === 1024) {
            res = 1;
            pow++;
        }
@avoidwork avoidwork self-assigned this Sep 25, 2019
@avoidwork avoidwork added the bug label Sep 25, 2019
@avoidwork
Copy link
Owner

Thanks for reporting this

@zypA13510
Copy link

For those who are trying to make sense of this change:

1PB != 1125899906842620 bytes, 1PB == 1125899906842624 bytes, yes.
But filesize is expected to round up the result, e.g. filesize(1048574) == '1 MB' although 1024*1024 == 1048576

Hope this helps those who look for changelog like me.

@avoidwork
Copy link
Owner

I hope you would understand the issue and the fix based on the details provided, and the single commit to address the issue. A changelog won't help you reason why something is modified, it's just a subset of the commit log.

@avoidwork
Copy link
Owner

avoidwork commented Oct 7, 2019

https://en.wikipedia.org/wiki/Changelog <--- seriously stop being so entitled with the notion of the changelog already, and either land it or stfu.

https://devhints.io/git-log <-- this is required reading

@zypA13510
Copy link

zypA13510 commented Oct 8, 2019

Without a changelog, the only way to determine if an upgrade is "safe" or not is to look at the commit log, which I was doing. And clearly I failed to understand this change at first look.

I'm not arguing with you whether providing a changelog is a good thing or not, I'm merely giving people (who look for the details of an update, people like me) a better understanding of this issue and that's it, what's so wrong about that? This is what I saw, and how I came to this issue, and it only makes me confused because 1125899906842620 is clearly not equal to 1PB. Your test case is even more confusing (to me at least). So that's why I decided to leave a note to future readers.

Btw, providing a changelog is not that difficult, you may want to look into conventional commits and semantic release

@jennifer-shehane
Copy link

Reading through every commit for every package that is a dependency of a project is not sustainable. I would argue that a changelog is a very good thing. I too came looking for changes and am reading entire threads of the project to see what changed, which is not ideal. @zypA13510 Thanks for your comment - it makes the issue and commit much clearer.

@avoidwork
Copy link
Owner

Maintaining a change log is a job of a technical writer. I am not a technical writer. Anyone that feels that one should exist is welcome to spend their time curating the git history to create whatever is deemed ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants