TextBox and decimal numbers

  • Thread starter Thread starter Alberto
  • Start date Start date
A

Alberto

I have a textbox and when I ttry to insert a decimal number like 900000,99
in this way:

txt.Text = number.ToString();

I see 900001.

It only happens in a proyect but I don't see why.
Can somebody help me?
Thank you?
 
Hi Alberto,

Try changing the type of your number to a double or decimal, rather than a
float.

Joe
 
The number already is decimal.

Joe Mayo said:
Hi Alberto,

Try changing the type of your number to a double or decimal, rather than a
float.

Joe
 
The only way I could get the same results as you was to set number to type
float. I tried this but it didn't reproduce the problem:

decimal number = 900000.99m;
string text = number.ToString();
Console.WriteLine(text);

How is number being set and how did you verify its value before calling
ToString()? Maybe you could post a small snippet of code that reproduces
the problem. What is your locale set to? Mine is en-US.

Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top