Double tryparse return value is inconsistent

68 Views Asked by At

I have a strange problem. When my custom formatted Hex value is tested with double.Tryparse it returns inconsistent results

For example

if (double.TryParse(dblValue, NumberStyles.Float, CultureInfo.InvariantCulture, out double x))

If the dblValue = "0E-63" the above statement returns true and if dblValue = "0E-5B" it returns false I expect both of these custom formatted hex values to return false in TryParse, so that my code handles them as not a number. What am I missing here.

other than this double and integers are working as expected.

1

There are 1 best solutions below

0
Marc Gravell On BEST ANSWER

0E-63 here is not hex - it is 0 x (10 to the power of -63) - in the same way that 1E-03 parses as 0.001 i.e. 1 x (10 to the power of -3).

This API does not parse hex.