## digitalmars.D.learn - how to transform decial point "3.15" to "3,15" comma?

• Cassio Butrico (5/5) Sep 15 2014 how to transform decial point "3.15" to "3,15" comma?
• Cassio Butrico (3/4) Sep 15 2014 Hello everyone, I am making a registry of real amounts, and need
• AsmMan (10/15) Sep 15 2014 Is the , (comma) the system decimal separator? if so, you can use
"Cassio Butrico" <cassio_butrico ig.com.br> writes:
```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?
```
Sep 15 2014
"Cassio Butrico" <cassio_butrico ig.com.br> writes:
``` 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 correctly. there is some
routine that do this?
```
Sep 15 2014
ketmar via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
```On Mon, 15 Sep 2014 22:47:32 +0000
Cassio Butrico via Digitalmars-d-learn
<digitalmars-d-learn puremagic.com> wrote:

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

Hello everyone, I am making a registry of real amounts, and need=20
trasformar fractional numbers, so print correctly. there is some=20
routine that do this?

why don't do just this:

void main () {
import std.stdio;
import std.string;
import std.array;
string s =3D "%s".format(3.14).replace(".", ",");
writeln(s);
}

but i believe that separator is locale-dependend, so maybe you should
just change locale at program startup?
```
Sep 15 2014
"AsmMan" <jckj33 gmail.com> writes:
```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()
```
Sep 15 2014
"AsmMan" <jckj33 gmail.com> writes:
```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
}

You can change/see current decimal separator using (assuming
Windows) http://www.softwareok.com/?seite=faq-Win-7&faq=78
```
Sep 15 2014
"Cassio Butrico" <cassio_butrico ig.com.br> writes:
```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
```
Sep 15 2014
"AsmMan" <jckj33 gmail.com> writes:
```On Monday, 15 September 2014 at 23:43:47 UTC, Cassio Butrico
wrote:
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

you're welcome! :)
```
Sep 15 2014