Dmitriy Zaslavskiy has asked a very good question:
“How come VC8 doesn't distinguish long double and double? I thought VC7 did. Have to go back and check.”
The short answer is: The types are distinct, but the sizes are the same.
The long answer is this: “double” and “long double” are distinct types in VC++ (all versions). The following code demonstrates this:
void foo(double x)
{
printf(“foo(double)\n”);
}
void foo(long double x)
{
printf(“foo(long double)\n”);
}
int main()
{
double d=0;
long double ld=0;
foo(d);
foo(ld);
return 0;
}
This will output
foo(double)
foo(long double)
So the two types are distinguishable, though both types are currently mapped to the same double precision format; that is, sizeof(d) == sizeof(ld). Much to my chagrin, VC++ still doesn’t have extended precision long doubles (yes, even in version 8.0!). This has been a point of longstanding criticism of our product. For years processors have provided the capability of extended precision, yet VC only provides support for double precision.
Why don’t we support extended precision in 8.0? I wish I could give a satisfactory answer. The decision was made before I started working on floating-point. The truth is that even had I and others insisted upon it, I seriously doubt the feature would have made the final cut. To support 80bit long doubles we’d have to implement several high-risk, costly changes to both the front-end and the optimizer.
However, the underlying reason is this: customers are not complaining about the lack of 80bit long doubles nor are they demanding it. True, William Kahan and other numerical VIPs have long criticized Microsoft for the lack of 80bit long doubles. However influential these people may be in their industry, it’s not they but our customers who largely determine which features get incorporated and which features get postponed. To my knowledge, VC's customers are not complaining about the lack of 80bit long doubles, nor are they demanding such support. Nor have trade journals and magazines criticized the product for lacking 80bit long doubles. The Visual C++ product managers take customer feedback very (very) seriously as they should. They would argue that if customers don't want the feature, why should we add it?
I argue that customers do want the feature, they just don't know it yet. If enough customers were to complain about the lack of 80bit long doubles and start demanding it, I feel quite confident that we’d get the feature. (Hint Hint!) I also contend that were we to add 80bit long doubles, more numerical programmers would start using our product. Unfortunately, I don’t have enough market analysis information to fully support this claim (my evidence is only anecdotal).
The upside is that for the next version of the product (VC9.0 that is), we will probably support 80 bit long doubles. At least that’s my hope and I'll be pusing for it. In fact I have a whole wish list of FP related items that I’d like to see in the next product. I think I’ll post them here... with enough feedback customers can strongly influence the VC++ product team to add the features.