I am excited to share one of the Julia packages I worked on during the summer.
InstaRound.jl is a small utility Julia package which extends Base.round with a more human readable rounding style. This is useful for anyone who prefers numerical outputs in a more interpretable format.
using InstaRound
julia> round(IGRound, 1_000_000; names=false)
"1.0M"
julia> round(IGRound, 1_000_000; names=true)
"1.0 Million"
Main Feature
Covers all representations up to 10^69 (‘Unvigintillion ’ - I never heard of it until this project).
Any form of a feedback will be greatly appreciated.
Special mention to @Skoffer for his brilliant (as always) conversion of the problem into a neat mathematical representation.
17 Likes
Juan
September 7, 2021, 3:23pm
2
Why not use common scientific notation?
1 Like
That could also be an option for users. The focus here was to move to more ‘grammar’ like conventions.
1 Like
This package is doing two separate things. 1) rounding a number. and 2) converting a number to a particular string representation. You might want to consider separating these features, although that would be somewhat more ambitious.
1 Like
Juan
September 8, 2021, 12:04am
5
And what convention is it using, the long or short scale?
The long and short scales are two of several naming systems for integer powers of ten which use some of the same terms for different magnitudes.
Some languages, particularly in East Asia and South Asia, have large number naming systems that are different from both the long and short scales, such as Chinese, Japanese, or Korean numerals and the Indian numbering system.
Much of the remainder of the world adopted either the short scale or the long scale for everyday counting powers of ten. Co...
jw3126
September 8, 2021, 6:36am
6
Seems short scale is used otherwise Univigintillion would be much bigger
According to that, the short scale was adopted for this project.
I second @jlapeyre ’s suggestion: rounding to human-readable quantities and converting to String
should be separate functionalities.
Eg you could make round
return a wrapper defined by your package that subtypes <: Real
, and have string
convert it to a string.
1 Like