Implicit conversion between single and double precision real #836
Replies: 1 comment
-
For question 1, I would say 3 and 4 depend on the routine it's being used in. As long as the subroutine and any subsequent calls in it will not be affected by the possible loss/gain in precision it should be fine, but it's probably better to use explicit types on bigger routines to keep any values from changing. For question 2, the explicit conversions are more of a best practice since it makes it easier to see where the conversions are occurring, so it might be good to add it in a case like this where the value could change. The |
Beta Was this translation helpful? Give feedback.
-
For the following subroutine:
There are 4 possible scenarios:
test
is compiled in single precision and the passed argumenta_in
is a single precision real. This is okay because case 1 will occur with no conversion.test
is compiled in double precision and the passed argumenta_in
is a double precision real. This is okay because case 2 will occur with no conversion.test
is compiled in single precision anda_in
is a double real. Case 2 will occur with implicit conversion from double to singletest
is compiled in double precision anda_in
is a single real. Case 1 will occur with implicit conversion from single to doubleFirst question: Are both 3) and 4) acceptable?
Second question: Is there an advantage for going the extra mile to check the type of
a_local
and useDBLE
orSNGL
function for explicit conversion?Beta Was this translation helpful? Give feedback.
All reactions