Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Double tryparse return value is inconsistent

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))

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading