Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Use Numeric Separators to Easily Read Big Numbers

Sometimes, it becomes difficult to read numbers that contain many digits.

For example, 1000 is readable but what about 1000000?

Yeap, it becomes pretty tricky to read.

In real life, we add commas ( , ) or punctuation ( . ) depending on where you live.

But because this is a number and not a string, we can’t add commas or dots as thousands indicators.

However, many modern languages give us the Numeric separator which is an underscore ( _ ) placed between characters in a number to make it easier to read.

Here’s an example in JavaScript:

In the above example, there are a few use cases when you’d want to use the numeric separator to make numeric notations more readable.


The numeric separator is also available starting with Python 3.6, Java SE 7, and C# 7.

In C++ this feature is called digit separator and it has been available starting with version 14.

Note that it is using simple quotation mark (  ) instead of ( _ ) underscore.

Happy coding


Let me know what you think about this article through comments below, or on Twitter at @pelu_carol.

If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.



This post first appeared on Neutron Dev, please read the originial post: here

Share the post

Use Numeric Separators to Easily Read Big Numbers

×

Subscribe to Neutron Dev

Get updates delivered right to your inbox!

Thank you for your subscription

×