Unfamiliar .D0 number syntax
12 views (last 30 days)
I've inherited some Matlab code that was previously adapted from Fortran, and the Matlab code has a syntax I'm not familiar with. Numbers end with .D0, so I see a lot of lines like:
a = b*5.D0;
which produces the same result as
a = b*5;
I haven't found any documentation for this syntax, but it's easy to deduce what it's doing:
My questions are:
- What is this syntax called?
- Is there any particular reason to use it?
- Can I safely delete every instance of .D0 from this code I've inherited?
Steven Lord on 7 Mar 2022
This is E notation. I believe MATLAB supports D as well as E because Cleve was inspired by Fortran, which as a comment on that page states "FORTRAN (at least since FORTRAN IV as of 1961) also uses "D" to signify double precision numbers in scientific notation."
x = 3.4e2
y = 3.4d2
The .D0 indicates that whatever value you're defining is an integer. All of z, w, and q are the same value (five.)
z = 5.0D0
w = 5.D0
q = 5D0