3 ms·
The author's lookup table is incorrect. The question being answered clearly wanted base2 engineering prefix units, rather than the standard base10 engineering
by mjevans 5y ago
The author's lookup table is incorrect.
The question being answered clearly wanted base2 engineering prefix units, rather than the standard base10 engineering prefix units.
suffixes = [ "EB", "PB", "TB", "GB", "MB", "KB", "B" ]
magnitudes = [ 2^60, 2^50, 2^40, 2^30, 2^20, 2^10, 2^0 ] // Pseudocode, also 64 bit integers required. (Compilers might assume unsigned 32 for int)
- returningfory2 5y agoThat code snippet is explicitly introduced in the article as not the author's.
- asdf3243245q 5y agoThat is not the author's code. That is pseudocode for one of the example answers that he is improving on. The author's code gives an option for the units: int unit = si ? 1000 : 1024;
- Fornax96 5y agoIf you do this you should add an 'i' to the prefixes to denote that you mean the binary notation. e.g: kiB, MiB, GiB, TiB, etc