Humanize.jl also works nicely for this, e.g.

digitsep(12345678, sep = "_")


https://github.com/IainNZ/Humanize.jl


On Friday, March 20, 2015 at 5:54:11 PM UTC+1, Peter Simon wrote:
>
> Also, perhaps you would be interested in the Formatting package:
>
>
> julia> using Formatting
>
> julia> format(1234567.89,commas=true)
> "1,234,567.89"
>
> julia> format(123456789,commas=true)
> "123,456,789"
>
> julia> usformat(x) = replace(format(x,commas=true),',','_')  # underscore 
> formatting
> usformat (generic function with 1 method)
>
> julia> usformat(1234567.89)
> "1_234_567.89"
>
> julia> usformat(123456789)
> "123_456_789"
>
>
>
> On Friday, March 20, 2015 at 9:11:25 AM UTC-7, Fabian Gans wrote:
>>
>> I am not sure if this would go through as a PR, but you would have to 
>> look in base/intfuncs.jl for the function signature: 
>>
>> function dec(x::Unsigned, pad::Int, neg::Bool)
>>
>> This generates the decimal representation for Integers. If you checked 
>> out and compiled Julia yourself you can simply modify this function, and 
>> after rebuilding julia you should see changes in how Integers get printed.
>> I don't know if there is a way to overwrite the function without 
>> rebuilding julia...
>>
>> Fabian
>>
>>
>> On Friday, March 20, 2015 at 11:59:39 AM UTC+1, Ken B wrote:
>>>
>>> I really appreciate the fact that I can input an integer with 
>>> underscores, as in 
>>>
>>> a = 1_000_000
>>>
>>>
>>> Would it be a silly suggestion to also print integers with underscores? 
>>> I sometimes find myself counting digits to interpret an output
>>>
>>> output => 1102160376
>>>
>>>
>>> Or is there a simple way for me to overwrite the standard integer 
>>> printing?
>>>
>>> Just trying to make Julia even better! :)
>>>
>>> Thanks,
>>> Ken
>>>
>>>
>>>

Reply via email to