- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
IFORT does not have this issue.
IFX power operator result differs when exponent is:
1. integer constant
2. integer variable or real constant
10.02**4 = 10080.24121
(p=4) 10.02**p = 10080.24219
- Tags:
- ifx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Single-precision reals have seven significant decimal digits (23+1 bits in binary). You are looking at the ninth significant digit, and the apparent differences are artifacts of the output format conversion.
If the difference bothers you, use an appropriate format specification and print no more than seven significant digits.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The double-precision real also have this issue. This code given here is just an example. The actual equations are very complex, and this issue causes a significant difference in final value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>The double-precision real also have this issue.
Please note, 10.02**4 is a single precision expression. 10.02_8**4 is a double precision expression.
Also, 10.02**4.0, although you can see this as an integer power, the compiler may generate code as if this were non-integer power.
Note, if your code is sensitive to least significant bits in the expression, you can promote the expression to larger precision. If your variables are single precision then promote the components and expression to double precision (then convert back to single precision)
If your variables are double precision, promote to quad precision (real(16)).
Yes, this is a tradeoff between speed and precision.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10080.240320160
Actual answer from HP35S and EXCEL, I would tend to believe them, first.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For now, I changed the floating-point model to /fp:strict for IFX.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page