Being strict on differentiating between IEC prefixes and SI prefixes.

One of the greatest things about rails is that it is so standards-compliant, no other framework that I have seen have complied to the HTTP standard (think REST) in such a degree that Rails does. Kudos to you all for that.

I think we (Rails community) should follow the line of standards compliance and also take it to the binary prefixes [1], i.e. kilobytes, megabytes, etc. For more than half a decade SI units has been a standard (occupying the prefixes kilo, mega, ...) Since the introduction of computers the prefixes has been misused in the IT industry for powers of 1024 but used correctly (for marketing reasons) by storage manufacturers to mean powers of 1000.

In 1999 IEC published the new standard for powers of 1024 (known as binary prefixes[1]). In 2008 this was harmonized with ISO standard in ISO/IEC IEC 80000-13:2008

I think it is a good time (for Rails 4) for Rails to conform to these standards. That means that every time a power of 1024 is used the IEC prefixes kibi, mebi, and so on are used and vice versa. Further every time a power of 1000 is used the SI prefixes are used, that is, kilo, mega, and so on and vice versa.

I have created a pull request (https://github.com/rails/rails/pull/7819) that implements two things (in two separate commits):

1) Rename all use of 1024 to use IEC prefix names

   a) Rename of core extension: 2.kilobytes => 2.kibibyte == 2*1024    b) Rename all use of these helpers within the Rails project.    c) Ensure that number the prefixes are KiB, MiB when dividing by    powers of 1024, and using KB, MB when dividing by powers of 1000    (that is when options[:prefix] => :si)

2) (Re)Introduced the posibility to use SI prefix names (meaning powers of 1000)    Introduced SI prefix helpers 2.kilobytes == 2*1000

Impact on Rails itself: None: All the useages has been renamed to use the semantically equivalent method (that is IEC names).

Impact on Rails projects: The use of core extensions 2.kilobytes, 2.megabytes will mean something else; A power of 1000 in Rails4 as opposed to a power of 1024 in Rails3. But the old behaviour can still be achieved by using IEC names instead such as 2.kibibytes or 2.mebibytes.

Footnotes: [1] Binary prefix - Wikipedia

Jarl

I’m -1 for this.

This pull request poses two problems in my mind. The changes are not backwards compatible, which could lead to some serious head scratching. Secondly, even though they’re a standard now, they’re not commonly used, which leads to more head scrathing.

Allen Madsen http://www.allenmadsen.com

2.kilobytes(prefix: :si) would make sense to be 2000, if anyone’s interested in doing so. -1 on everything else.

One of the great things I like about rails is not always being tied to full backwards compatibility causing a more and more bloated core every major release. In my mind a plugin that puts everything back would solve that issue, for those who need it.

That other objection still gives me pause though… I suspect the difference between IEC and SI units is still not commonly known even among programmers. So this may not be the right time to do this yet? I dunno, just my thoughts, I’d be happy either way.

Just to be clear, this is not just a visual change in prefix, but much a more basic functional mathematical change of how the units are calculated and converted too. A mere prefix would be superficial in comparison.

Dave

OK, pushed. I can’t push my own database data up, so I’ll get four questions up there for you.

-Geoff

Thanks Geoff, whatever that means.

So very sorry about that misdirected reply.

Dear community.

Thank you for all your time an feedback on this issue. As a result of your valuable feedback I have opened an issue (ActiveSupport::NumberHelper#number_to_human_size provides ambiguous information · Issue #7830 · rails/rails · GitHub) describing the issue. I have proposed another much less intrusive and backward compatible pull request (Using the right notation for the right exponent base. by jarl-dk · Pull Request #7829 · rails/rails · GitHub) to resolve the notation only. I suggest you comment on the issue or the pull request as you see fit.

Thanks in advance.

Jarl