JF said:
Is there a way to force calculation included in an
Excel sheet to use IEEE 754 single precision format?
I have experimented extensively over the years, and AFAIK, the answer is
"no".
JF said:
What is the simpler solution to do this?
Do your calculations in VBA, where you declare variables Single instead of
Double.
But caveat: VBA tries to keep intermediate calculations in the 80-bit
floating-point registers of the FPU. In that context, your requirement is
unclear.
For example:
Dim x as Single, y as Single, z as Single
x = 1.1
y = 2.2
z = 3.3
x = x + y + z
The expression x+y+z will be computed with 80-bit precision, then rounded to
single precision.
If that is acceptable, fine. Otherwise you would need to code complex
expressions carefully. For example:
x = x + y
x = x + z
Of course, even then, x+y is computed with 80-bit precision. But there is
nothing you can do about that.
(Note: My constants and arithmetic operations might not be a good example
because it might not make any difference in that case. But hopefully it is
sufficient to understand what I mean conceptually.)
As an alternative, it is possible to call a C++ DLL routine that causes the
FPU to round pairwise operations to single precision. However, VBA resets
to its default each time we exit VBA back to Excel. So you have to call the
DLL routine from each VBA procedure that might be called from Excel.
Moreover, it appears that some other computer languages set the FPU rounding
state to conform to their own requirements; for example, Fortran DLL
routines. So it is ill-advised to rely on what you set in a C++ DLL
routine.