0.00007m -> 7E-5 ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello.
I'd want to see the right value that inserted, but very small value like
0.00007m doesn't displayed exactly(displayed 7E-5).

ex)
decimal b = 0.00007m;

TextBox.Text = b.ToString(); => 7E-5
TextBox.Text = b.ToString("F"); => 0.00
TextBox.Text = b.ToString("0.00000"); => 0.00007 (but 0.00000007 not
supported)
TextBox.Text = b.ToString("0.0000000000"); => 0.0000700000

so, I want to know the string format type that all decimal values show the
values as it is.

decimal b = 0.00007m; ( for all decimal cases like 0.0000007m,
0.0000000000007m )
TextBox.Text = b.ToString(????); => 0.00007

Please, help me~ ^^

ps. maybe understanding this question is harder than solving..^^ sorry and
thanks..
 
Where are you putting the data to be shown at ? I compiled this code and
it showed up exactly perfect, the way it should:

decimal d = 0.00007m;
string test = d.ToString();
MessageBox.Show(test);

I got a response of a messagebox showing 0.00007

The problem could be perhaps that whatever you are showing the data in
cannot support a number that big(or small)?

Lowell
 
Thank you for answering..
but I use the same code that you suggest, I got 7E-5...
maybe other configulation is different between our machines..
is there anybody knows this?
 
Odd,

As far as I know the only configuration differences are in currency
formats and the use of , or . as decimal point.

Regular output for me is always 0,00007 (, is the decimal point) and
scientific format ("E") is output as 7,000000E-005 not 7E-5.

You might try the General specifier ("G") which outputs the number in the
shortest of fixed or scientific. This always gave me 0,00007.

Btw, "0.0000" == "F5", easier to write :)
 
Doubles seem to use the scientific format you mentioned. Are you sure you're
using decimal?

For me, it's:

0.00007.ToString() => 7E-5
0.00007m.ToString() => 0,00007

even

0.0000000000000000000000000007m.ToString()
yields
0,0000000000000000000000000007

HTH,
Stefan
 
Back
Top