I’m working with string data that has numbers in exponent notation, e.g., "-2.90854e-17” and thought Val() handled, that, but apparently it doesn’t. And for kicks, I also tried storing the string in a Variant and then pulling out the .DoubleValue. Zero is the returned double value in both instances. Perhaps I’m beyond the precision of what the debugger can show?
Before I make my own, is there a built in function to parse strings in exponent notation?
Update: Val() indeed does exponent notation! However, the documenation doesn’t mention this, or provide an example. I’ve submitted a feedback:
Var s As String, d As Double
s = "-2.90854e-17"
d = s.ToDouble
System.DebugLog (d.ToString)
This works and looks simplest, to me. If you break after the debuglog, d shows up as 0. in the debugger, but as we see, it in fact has the correct value.
Edit: a quick perusal of the doc for String shows up .ToDouble straight waway, although there is no example for a string with an exponent. Perhaps the OP could modify his Issue to add that doc omission.
There are 2 sides, and 2 needs. ToDouble() for usually poorly managed user input, and .Val() for universal values as stored contents in DBs or JSON I/O (always dot as decimal). Such values must use only a dot as decimal separator in their inner workings and I/O (that can be converted to comma or whatever at the user presentation layer).
When converting them, there’s no need the extra code and loss of performance creating temporary locale objects, just use Val()
While this is true, the OP gave us a string to be converted and made no mention of any locale. What this illustrates is the problems that arise when storing data in a user presentation format, rather than the internal representation, such as a straighforward double or seconds since the epoch in the case of date/time.