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

bytes to kilobytes, megabytes etc #312

Closed
markve-sa opened this issue Jan 5, 2016 · 6 comments
Closed

bytes to kilobytes, megabytes etc #312

markve-sa opened this issue Jan 5, 2016 · 6 comments
Milestone

Comments

@markve-sa
Copy link

The conversion is not in line with the International System of Units.

Currently Numeral-js converts 1024 bytes to 1 Kilobyte (kB) but 1024 bytes has officially been a Kibibyte (KiB) since 1998

1000B = kB (kilobyte)
1000000 = MB (megabyte)
1000000000B = GB (gigabyte)

1024B = KiB (kibibyte)
1048576B = MiB (mebibyte)
1073741824 = GiB (gibibyte)

Most operating systems file managers have been updated to report the size as defined in the standard.

Is there any chance that Numeral-js will be updated ?

@joaomvfsantos
Copy link

+1

1 similar comment
@sirianni
Copy link

sirianni commented Mar 4, 2016

+1

@jeancornic
Copy link

+1
See https://en.wikipedia.org/wiki/Mebibyte for example.

@leeway23
Copy link

leeway23 commented Aug 17, 2016

Hi All,

For your parameter e.g. number of bytes of memory used called ‘avgRSS’ one can create a scripted field in Kibana with the following formula:

name of the scripted field: avgRSS_main_reco
Type : Bytes
Script: doc[‘avgRSS'].value * pow(1.024, floor(ln(doc['avgRSS'].value)/ln(1000)))

This corrects for the wrong binary conversion factor finally using decimal one in line with the decimal unit labels.

It carries with it the inconvenience, that one has to be alert in case Kibana fixes the issue in the future. but as far as I have heard, this is not going to happen anytime soon (problem located in one of the upstream libraries). Also, Kibana applies this correction factor per-document-value, i.e. it will not show a correct number after aggregation ! Another option, less elegant, but functional is :

screen shot 2018-04-09 at 17 36 48

Cheers,
J.

PS: for general n-core jobs e.g.: (doc[‘avgRSS'].value/doc['ncores'].value) * pow(1.024, ln(doc['avgRSS'].value/doc['ncores'].value)/ln(1000))

@adamwdraper
Copy link
Owner

1.5.6 added a new format you can use ib to display kibibytes. 2.0.0 will finish that conversion and convert kilobyte to be calculated using 1000 instead of 1024.

@spe-shun
Copy link

spe-shun commented Apr 12, 2022

image
http://numeraljs.com/#format 1024 -> 0b -> 1 KB has not change yet

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

7 participants