Yes, use integer will coerce the overload result back to integer format, as will using the int() function. But these are just workarounds. (And use integer is worse because it affects all arithmetic within a block, or the entire application, if placed at the top as you recommended.)
The issue is how to stop the needless coercion of the integer return value (1000000000000000) to a floating-point result (1e+15) in the first place.
Remember: There's always one more bug.
| [reply] [d/l] [select] |
The manual, clearly describes that "use integer;" controls the actual computation, rather than coercing anything afterwards. Specifically, when use integer is in effect, floating point numbers will be rounded, but integers will not be coerced into floating point - they will stay integer before during and after any computation in the relevant scope.
I suggested placing it at the top of the example program because the example program had only one purpose - to show where float conversion took place for 16 digits. This should not be construed as a recommendation to always place it at the top of every program.
Re your subsequent objection to the block scope nature of use integer, I can't conceive of any actual case where the use of
{ use integer;"
# statements where the pragma is required
# ...
"}"
wherever the pragma is actually required, can fail to control the scope - curly brackets can be applied anywhere you like!
| [reply] [d/l] |