Selective check to compare float value of two text fields
I am using a custom validator to compare the value in two text fields. This compares the penalty values. But he says that "025" and "25" are different. Can floating point comparison do it.
the custom validator I'm using is
<asp:CompareValidator id="compval" runat="server" ControlToValidate="txtBox1"
ErrorMessage="There values are not equal."
Enabled="False" ControlToCompare="txtBox2">*</asp:CompareValidator></TD>
Please let me know if possible.
+1
source to share
4 answers
The only thing I can think of without seeing your validation code is that 025 is interpreted as an octal number (in C, putting a zero in front of an integer means it in base 8). Then 025 will be 21 in base-10 and your two numbers will not be the same.
I'm not sure how you came up with this. I checked several Parse () functions and they all convert the string "025" to base-10 25.
+1
source to share