Bob Jones wrote:
"Walter Bright" <newshou...@digitalmars.com> wrote in message
news:hqq3qv$2sp...@digitalmars.com...
Bob Jones wrote:
You can set the internal precision of the x87 unit to 32, 64 or 80 bits,
it just defaults to 80, and as there's little if any performance
difference between the 3 modes, thats how it's usualy set.
Despite those settings, the fpu still holds intermediate calculations to
80 bits. The only way to get it to round to the lower precision is to
write it out to memory then read it back in. This, of course, is
disastrously slow.
Not true. If you load from memory it will keep the precision of what it
loads, but the results of any calculations will be rounded to the lower
precision.
For example...
====
long double a = 1.0/3.0;
long double b = 0.0;
SetCtrlWord(GetCtrlWord() & 0xFCFF); // Set single precision
__asm
{
FLD [a] // ST(0) == +3.3333333333333331e-0001
FADD [b] // ST(0) == +3.3333334326744079e-0001
FSTP ST(0)
}
Then there was something else that wasn't rounded down, as the Java people found
out.