On Mon, Sep 18, 2000 at 06:40:23PM +0200, Robert Hegemann wrote:
> Frank Klemm schrieb am Mon, 18 Sep 2000:
> > ::  
> > ::  1)      one type is long double, the other will be casted to long double
> > ::  2)      one type is double, the other will be casted to double
> > ::  3)      one type is float, the other will be casted to float
> > Fully wrong.
> > The rest I haven't checked.
> > 
> > -- 
> > Mit freundlichen Grüßen
> > Frank Klemm
> 
> You may like to look into Microsoft Developer Studio's help
> text, section "Usual Arithmetic Conversions", as you call 
> this to be wrong too.
> 
Microsoft's Developer Studio is fine, but far beyond being standard conform.
Gcc is a little bit better, especially with a lot of force-conformity
flags.

#include <stdio.h>

float x1 = 1.e30;
float x2 = 1.e31;
float x3 = 1.e32;

int main ( void )
{
    float x4;

    x4 = x1*x2*x3 / (x1*x2 + x2*x3 + x3*x1);

    printf ( "%g\n", x4 );
    return 0;
}

The code line x4=... is equivalent to

    x4 = (float) ((double)x1*x2*x3 / ((double)x1*x2 + (double)x2*x3 + (double)x3*x1));

Note, that the optimizer of gcc-2.95 isn't standard conform.

One exception for implicit type conversations are functions calls of prototyped
functions (Note: Not in K&R2, but in ANSI C3.159-1989 and later). 

-- 
Frank Klemm

PS: Nice try for MS VC++:

    unsigned __int64  x = 123456789012345LL;
    double            y;

    y = x;

--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )

Reply via email to