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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
For the following subroutine:
There are 4 possible scenarios:
testis compiled in single precision and the passed argumenta_inis a single precision real. This is okay because case 1 will occur with no conversion.testis compiled in double precision and the passed argumenta_inis a double precision real. This is okay because case 2 will occur with no conversion.testis compiled in single precision anda_inis a double real. Case 2 will occur with implicit conversion from double to singletestis compiled in double precision anda_inis 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_localand useDBLEorSNGLfunction for explicit conversion?Beta Was this translation helpful? Give feedback.
All reactions