I have a scenario where my datatable column is 32.000, convert it float and insert into database

while converting string to double , the value is 32, i want it with 32.000 (3 decimal points). String format doesn’t work , i want 32.000 it in a float variable

Hi @jyerva,

You can try this,

Math.Round(Convert.ToDouble(“32”), 3).ToString(“F3”)

Using “F3” ensures that 3 decimal places are shown.

Hope this helps!

32.000 is only a visible representation of 32 and only relevant as soon as you cast it to a string.

For precision in 3 decimals with fractured values you can round it to 3 decimals, but 32.000 = 32 no matter how many decimals you add.

this is Math.Round(Convert.ToDouble(“32”), 3).ToString(“F3”) again a string variable. i should insert the data into DB column which is of float datatype, In DB it should show as 32.000.

I tried inserting the string variable (32.000) in DB float column , it was showing 32.