c# - Format doubles with General numeric format and pad right with zeros -
i'm trying output doubles of various sizes, negative , non-negative, columns. use g5 standard numerical format exponential format when appropriate (i.e. values tiny), regular formatting otherwise. values padded zeros appropriately line in columns (i.e. pad zeros on right normally, , pad zeros before e in exponentials). currently, have:
string.format("{0} {1} {2}", a.tostring("g5"), b.tostring("g5"), c.tostring("g5"));
this doesn't work great since doesn't pad. output this:
1.234000000 0.123400000 1.23450e-03 4.56780e-08 -1.2345e-09 0.001234000 // negative signs can line else -12.34500000 0.045678900 -1.23450e-06 // or line each other, whatever easier, not both
how can achieve this?
edit: using :
format {0:10}
above numbers yields:
1.234 0.1234 0.0012345 4.5678e-08 -1.2345e-09 0.001234 -12.345 0.045679 -1.2345e-06
Comments
Post a Comment