# Add a size format method for converting Numbers to automatic byte units

**URL:** <https://es.discourse.group/t/add-a-size-format-method-for-converting-numbers-to-automatic-byte-units/1446>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [August 31, 2022, 11:34pm UTC](https://es.discourse.group/t/add-a-size-format-method-for-converting-numbers-to-automatic-byte-units/1446 "2022-08-31T23:34:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rudxain](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/rudxain/32/2272_2.png) [@Rudxain](https://es.discourse.group/u/Rudxain)\
**Post date:** [August 31, 2022, 11:34pm UTC](https://es.discourse.group/t/add-a-size-format-method-for-converting-numbers-to-automatic-byte-units/1446/1 "2022-08-31T23:34:59Z")

</div>

[Original GH Issue](https://github.com/rwaldron/proposal-math-extensions/issues/32)

The purpose of this method is to make it easy for devs to automatically convert any numeric value (`Number`s, `BigInt`s, maybe even `Decimal`s) to a string representing a binary data size/length/count, and being able to choose any standard system like SI or IEC (and maybe more in the future).

[This S.O. question](https://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable-string) (and its comments) show how hard it is to get the implementation right, and the number of views and upvotes shows how useful such a function would be (yes, I'm aware I may have committed a fallacy).

JS code is often used to deal with files (or just data in general), and many times it is necessary to display statistics about the data in a user-friendly manner

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/senocular/32/642_2.png) [@senocular](https://es.discourse.group/u/senocular)\
**Post date:** [September 1, 2022, 2:33am UTC](https://es.discourse.group/t/add-a-size-format-method-for-converting-numbers-to-automatic-byte-units/1446/2 "2022-09-01T02:33:27Z")

</div>

Related: [Automatic unit conversion for Intl.NumberFormat](https://es.discourse.group/t/automatic-unit-conversion-for-intl-numberformat/763)

---

<div class="post-metadata">

**Author:** ![Rudxain](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/rudxain/32/2272_2.png) [@Rudxain](https://es.discourse.group/u/Rudxain)\
**Post date:** [September 3, 2022, 11:20pm UTC](https://es.discourse.group/t/add-a-size-format-method-for-converting-numbers-to-automatic-byte-units/1446/3 "2022-09-03T23:20:54Z")

</div>

Thank you for the link. I couldn't find a related post
