how to transform decial point 3.15 to 3,15 comma?
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?
Re: how to transform decial point 3.15 to 3,15 comma?
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?
Re: how to transform decial point 3.15 to 3,15 comma?
On Mon, 15 Sep 2014 22:47:32 + 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 trasformar fractional numbers, so print correctly. there is some routine that do this? why don't do just this: void main () { import std.stdio; import std.string; import std.array; string s = %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? signature.asc Description: PGP signature
Re: how to transform decial point 3.15 to 3,15 comma?
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()
Re: how to transform decial point 3.15 to 3,15 comma?
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-7faq=78
Re: how to transform decial point 3.15 to 3,15 comma?
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
Re: how to transform decial point 3.15 to 3,15 comma?
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! :)