Note: that word doesn't work properly for negative numbers. This is better:
: number>string-with-commas ( str -- str' )
[
abs number>string "." split1
[ reverse 3 <groups> "," join reverse ] dip
[ "." glue ] when*
] [ neg? [ "-" prepend ] when ] bi ;
On Fri, Jun 16, 2017 at 4:29 PM, John Benediktsson <mrj...@gmail.com> wrote:
> We don't have that kind of locale support right now, but you could use
> something like:
>
> : number>string-with-commas ( str -- str' )
> number>string "." split1
> [ reverse 3 <groups> "," join reverse ] dip
> [ "." glue ] when* ;
>
>
>
> On Fri, Jun 16, 2017 at 4:18 PM, Alexander Ilin <ajs...@yandex.ru> wrote:
>
>> Hello!
>>
>> Is there a standard way to output a number with comma separators
>> grouping the thousands?
>>
>> ```
>> 1,000,000 num>str-grouped
>>
>> "1,000,000"
>> ```
>>
>> ---=====---
>> Александр
>>
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk