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

Add support for binary units (KiB, MiB, etc.) #1

Closed
ggtools opened this issue Mar 26, 2017 · 3 comments
Closed

Add support for binary units (KiB, MiB, etc.) #1

ggtools opened this issue Mar 26, 2017 · 3 comments

Comments

@ggtools
Copy link

ggtools commented Mar 26, 2017

The current system uses decimal factors: 1K = 1000, 1M = 1000, etc. In many cases, it's important to use binary factors: 1K = 1024, 1M = 1024M, etc.

@c2h5oh
Copy link
Owner

c2h5oh commented Mar 26, 2017

It is using binary factors right now - sizes are defined here https://github.com/c2h5oh/datasize/blob/master/datasize.go#L13-L19 as follows:

	B  ByteSize = 1
	KB          = B << 10
	MB          = KB << 10
	GB          = MB << 10
	TB          = GB << 10
	PB          = TB << 10
	EB          = PB << 10

<< is a left bit shift operator. << 10 means shift bits left by 10 positions, which for unsigned integers is an equivalent of multiplying by 2^10 = 1024.

@ggtools
Copy link
Author

ggtools commented Mar 26, 2017

Ooops missread. Sorry.

@ggtools ggtools closed this as completed Mar 26, 2017
@c2h5oh
Copy link
Owner

c2h5oh commented Mar 26, 2017

No worries - it's good to see someone else complaining about "marketing megabytes", despite the fact it was unnecessary in this case :-)

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

No branches or pull requests

2 participants