how to transform decial point "3.15" to "3,15" comma?

AsmMan via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 15 16:17:50 PDT 2014


On Monday, 15 September 2014 at 22:45:50 UTC, Cassio Butrico 
wrote:
> how to transform decial point "3.15" to "3,15" comma?
>
> Hello everyone, I am making a registry of real amounts,
> and need trasformar fractional numbers,
> so print coretamente.
>
> there is some routine that do this?

Is the , (comma) the system decimal separator? if so, you can use 
C intero and include locale.h header (in D, the respective 
module) call setlocale(LC_NUMERIC, "") function and then 
printf("%g", 3.5) will output (if decimal separator is the 
comma): 3,5

I haven't tested it in D but I think D's writefln() will behave 
exactly same as C's printf().. but it didn't you're free to call 
C's printf()


More information about the Digitalmars-d-learn mailing list