go-units icon indicating copy to clipboard operation
go-units copied to clipboard

FromHumanSize accepts MiB but returns MB

Open smoser opened this issue 6 years ago • 2 comments

One might expect that FromHumanSize("1MiB") would either

  • return error
  • return units.MiB (1024 * 1024 * 1024)

Currently it does not raise error and returns units.MB (1000 * 1000 * 1000)

smoser avatar Feb 12 '19 17:02 smoser

Yes, this is the way it works. I think we can fix this and accept e.g. KB as "human size" (1000) and KiB as "computer size" (1024), defaulting to "human size" for "FromHumanSize" and to "computer size" for "RAMInBytes".

Problem is, this will make things slightly incompatible with the current behavior.

kolyshkin avatar Apr 28 '22 19:04 kolyshkin