D.gnu - Output of std.format for float difference between DMD and GDC
- BoraxMan (14/14) Dec 04 2019 I have noted that DMD and GDC provide a different output to the
- BoraxMan (4/18) Dec 04 2019 I figured it out, its my lack of experience in D.
- Iain Buclaw (6/24) Dec 07 2019 It's a phobos library bug.
I have noted that DMD and GDC provide a different output to the following line of code. writeln(format("$%-12,3.2f",66543.22)); DMD outputs $66,543.22 GDC outputs $66,543.22 , As you can see, GDC puts a superflous comma at the end. The goal of this line is to convert a float to a monetary representation, therefore DMD is what I want and GDC not. The question is, is the line of code in error? If not, does this mean there is a bug with GDC's libphobos? Regards, Dennis
Dec 04 2019
On Wednesday, 4 December 2019 at 09:41:58 UTC, BoraxMan wrote:I have noted that DMD and GDC provide a different output to the following line of code. writeln(format("$%-12,3.2f",66543.22)); DMD outputs $66,543.22 GDC outputs $66,543.22 , As you can see, GDC puts a superflous comma at the end. The goal of this line is to convert a float to a monetary representation, therefore DMD is what I want and GDC not. The question is, is the line of code in error? If not, does this mean there is a bug with GDC's libphobos? Regards, DennisI figured it out, its my lack of experience in D. format("$%-*,3.2f",x.dig,x); where x is the floating point value works as expected.
Dec 04 2019
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Wednesday, 4 December 2019 12:16, BoraxMan via D.gnu <d.gnu puremagic.com> wrote:On Wednesday, 4 December 2019 at 09:41:58 UTC, BoraxMan wrote:It's a phobos library bug. https://issues.dlang.org/show_bug.cgi?id=20069 -- IainI have noted that DMD and GDC provide a different output to the following line of code. writeln(format("$%-12,3.2f",66543.22)); DMD outputs $66,543.22 GDC outputs $66,543.22 , As you can see, GDC puts a superflous comma at the end. The goal of this line is to convert a float to a monetary representation, therefore DMD is what I want and GDC not. The question is, is the line of code in error? If not, does this mean there is a bug with GDC's libphobos? Regards, DennisI figured it out, its my lack of experience in D. format("$%-*,3.2f",x.dig,x); where x is the floating point value works as expected.
Dec 07 2019