Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does IsNumeric("1.23D45") return True?

For the longest time, I thought IsNumeric("1.23E45") returned True because the "E" stands for scientific notation, making 1.23E45 be 1.23x1045.

Recently I noticed IsNumeric("1.23D34") also returned True, and I'm stumped about why.

Both D and E produce the same result:

?val("1.23d45")
 1.23E+45 

?val("1.23e45")
 1.23E+45 

How come?

like image 545
Mathieu Guindon Avatar asked Apr 20 '16 04:04

Mathieu Guindon


1 Answers

This came up in chat


According to Wikipedia...

FORTRAN also uses "D" to signify double precision numbers.

"UH Mānoa Mathematics » Fortran lesson 3: Format, Write, etc". Math.hawaii.edu. 2012-02-12. Retrieved 2012-03-06.

VBA still has many traces of its BASIC ancestor (line numbers, GoSub..Return, Rem, etc.) - it just so happens that BASIC finds its roots in... FORTRAN.

So that "D" for scientific notation is apparently nothing more than a blast from the past.

Bottom line, avoid confusing whoever is maintaining your code, and stick to "E" (or "e"). But know that "D" (or "d") is also supported, if you ever need to port some FORTRAN code to ...VBA.

like image 187
4 revs Avatar answered Sep 27 '22 21:09

4 revs