[omniORB] VC6 Compiler Warning?

Simkin, Rick rsimkin@htc.com
Wed, 25 Apr 2001 09:57:02 -0500


Olaf Meding wrote:

> When I compile my code using VC6 I get an obvious warning.  This must be a
> known issue?  Here is the warning:
>   warning C4305: 'initializing' : truncation from 'const double' to 'const
float'
>
> Here is the code produced by the IDL compiler that causes the warning:
>   extern const CORBA::Float invalidFloat=-1.00000001335e-010;

Stroustrup says this about C++

    By default a floating-point literal is of type double.
     . . .
    If you want a floating-point literal of type float, you can define
    one using the suffix f or F.

Certainly the constant above is too long for most implementations of
float, which store about 7 decimal digits. In storing it into a float,
the compiler must lose precision.  If you store the value in a double,
(common implementations store about 15 digits), the value will include
those last 5 digits.

================ I speak for myself, not my employer =================
Rick Simkin            rick.simkin@htc.com           +1 (312) 697-2949
Goldman Sachs/Hull Group * 311 S. Wacker #1400 * Chicago IL 60606-6623