digitalmars.D.learn - std.format and floating point issue
- codephantom (10/10) Oct 29 2017 Can anyone help me to understand why the format in the second
- =?UTF-8?Q?Ali_=c3=87ehreli?= (4/19) Nov 01 2017 Thanks for letting me know about this new feature. :) I agree with you
- jmh530 (9/29) Nov 01 2017 Was just looking at the examples on std.format. There is also
Can anyone help me to understand why the format in the second writeln below, does not format the output with commas? -------------------------------- void main() { import std.stdio, std.format; writeln( format("%,.1f", 84543432.951172) ); // 84,543,433.0 writeln( format("%,.0f", 84543432.951172) ); // 84543433 } ------------------------------
Oct 29 2017
On 10/29/2017 03:13 AM, codephantom wrote:Can anyone help me to understand why the format in the second writeln below, does not format the output with commas? -------------------------------- void main() { import std.stdio, std.format; writeln( format("%,.1f", 84543432.951172) ); // 84,543,433.0 writeln( format("%,.0f", 84543432.951172) ); // 84543433 } ------------------------------Thanks for letting me know about this new feature. :) I agree with you that it's a bug. Ali
Nov 01 2017
On Wednesday, 1 November 2017 at 19:06:42 UTC, Ali Çehreli wrote:On 10/29/2017 03:13 AM, codephantom wrote:Was just looking at the examples on std.format. There is also this: writeln(format("%,f", 1234567.891011)); // "1,234,567.891,011" which is what you would expect, I suppose, but still isn't what anyone would want. What you'd want is writeln(format("%,.0f", 1234567.891011)); // "1,234,567" which may not currently be tested. Someone should file a bug report.Can anyone help me to understand why the format in the second writeln below, does not format the output with commas? -------------------------------- void main() { import std.stdio, std.format; writeln( format("%,.1f", 84543432.951172) ); // 84,543,433.0 writeln( format("%,.0f", 84543432.951172) ); // 84543433 } ------------------------------Thanks for letting me know about this new feature. :) I agree with you that it's a bug. Ali
Nov 01 2017