I am using a text box to capture a percentage value. Example. .95676
I am using the following code to parse the string into a floating point number.
string pctValue = txtPctValue.txt // Get value from textbox
Float pctFloat = float.parse(pctValue) // Parse string into float variable
The problem is the value of pctFloat variable is something like .9567694567
It seems to want to add its own decimal place assingments.
My Question is:
How to you control the number of decimal places when converting a string to a float. This is important as the calculations I have to use from this data is critical that it be accurate. Any help is appreciated.
Start Free Trial