printf() - Local decilmal separator

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

printf() - Local decilmal separator

Alexandre Billon
Hello,

1st question : Is there a way to tell printf() to display the decimal separator set in the OS ?

For example, the decimal separator in my OS is set to comma (,), I would like printf() to display the comma as the decimal separator.

sqlite> select printf('%.2f %%', 25.365419);
25.37 %

2nd question : Is there a way that printf displays thousand separators and decimal separators ?
sqlite> select printf('%,.2f %%', 25566425.365419);
25566425.37 %
sqlite> select printf('%,f %%', 25566425.365419);
25566425.365419 %
sqlite> select printf('%,d %%', 25566425.365419);
25,566,425 %

I haven't found anything here : https://www.sqlite.org/printf.html

Best Regards

Alex
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: printf() - Local decilmal separator

James K. Lowden
On Tue, 12 Mar 2019 16:08:24 +0000
Alexandre Billon <[hidden email]> wrote:

> 1st question : Is there a way to tell printf() to display the decimal
> separator set in the OS ?
>
> For example, the decimal separator in my OS is set to comma (,), I
> would like printf() to display the comma as the decimal separator.

You may want to return the value in native form and use your C library
to format it.  Posix defines the single-quote character as a modifier
that does just what you want:


         ''' (apostrophe)
        Decimal conversions (d, u, or i) or the integral portion of a
        floating point conversion (f or F) should be grouped and
        separated by thousands using the non-monetary separator
        returned by localeconv(3).

--jkl
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users