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

Cassio Butrico via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 15 16:43:45 PDT 2014


On Monday, 15 September 2014 at 23:24:13 UTC, AsmMan wrote:
> On Monday, 15 September 2014 at 23:17:51 UTC, AsmMan wrote:
>> 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()
>
> The code is the following:
>
> import std.stdio;
> import std.c.locale;
>
> void main()
> {
> 	setlocale(LC_NUMERIC, "");
> 	writeln(3.5); // 3,5
> }
>
Okay,

Thanks everyone, that was it


More information about the Digitalmars-d-learn mailing list