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

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 15 16:16:31 PDT 2014


On Mon, 15 Sep 2014 22:47:32 +0000
Cassio Butrico via Digitalmars-d-learn
<digitalmars-d-learn at 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?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20140916/887215c3/attachment-0001.sig>


More information about the Digitalmars-d-learn mailing list