Eric Fleegal's WebLog

. . . .

Are long doubles 64 or 80 bit?

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.

Published Thursday, June 10, 2004 11:40 AM by ericflee

Comments

 

Dmitriy Zaslavskiy said:

Hi Eric,
Thanks for you comments.
I have not done intensive math computing in a while, and the fact that VC started to support long double (80bit) was second hand.
At that time, we decided to go with Watcom, which produced better code than VC. Now days (IMO) a lot of customers choose Intel compiler when they need to do computationally intensive work. (Maybe that is why they do not complain about VC)

As a side note: why was 53bit bits is kept for default even for fp:fast mode?
June 11, 2004 6:49 AM
 

Igor Abramov said:

Well, I was in desperate need for 80-bit
long doubles. Now I coded this type as set
of asm inlines and application prototype
shipped in such form. But the production
version will be done for amd64, in 64-bit mode
for performance reasons, and VS 2005 will not
have inline assembler. This means rewriting
some code again.
July 1, 2004 7:09 AM
 

John Hooper said:

The lack of VC support for 80-bit, and even more, the lack of CLEAR DOCUMENTATION of this bug (which is what it is) cost my reputation very dearly, almost as much as Microsoft's.

I stupidly recommended Microsoft tools for an important scientific application. The code was later taken and compiled to run on Linux. Guess what? The results didn't match!

This app deals with up to quadrillions of atoms. I assumed, naturally, that the Linux guy was wrong. Finally, after looking around everywhere, I found a tiny admission by Microsoft about how they arbitrarily and against standards (to cheat on benchmarks) switched long double back to double. To make matters worse, THERE IS NO WAY AROUND IT! Well, maybe assembler.

It was too late, the work went to Linux and the other programmer and I was kicked off the project. Windows and VC were also kicked off the project, after much jeering and derision.

I immediately checked VC7 and it was still there. Sickening. Still no way around it. Stupid.

Stop embarrassing yourselves and your supporters. You have no idea how much ground you have lost in academic settings. Why do you want to be a joke?

PowerBasic can do 80-bit precision for god's sake.

I am turning over one of my computers to Linux and GCC, which I HATE. What else can I do?
July 13, 2004 10:58 AM
 

Youda He said:

I am using VC and need long double badly, can any one recommand a compiler that can support it? In some of the inner loop I need as much precision as I get, (without going all the way to software high precision package).
July 15, 2004 4:32 PM
 

Eric Fleegal s WebLog Are long doubles 64 or 80 bit | Hair Growth Products said:

June 13, 2009 8:36 AM
 

Eric Fleegal s WebLog Are long doubles 64 or 80 bit | low cost car insurance said:

June 17, 2009 12:30 AM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker