Re: doubles and floats

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Dennis Myrén (dennis_at_oslokb.no)
Date: 09/28/04


Date: Tue, 28 Sep 2004 11:32:47 +0200

Sorry;
"It requires an implicit conversion"
should be
"It requires an explicit conversion"

-- 
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dennis Myrén" <dennis@oslokb.no> wrote in message 
news:7aa6d.9441$WW4.150194@news4.e.nsc.no...
> It requires an implicit conversion because double to float conversion is 
> potentially unsafe
> and might throw an exception.
> In your case, you may change
> fltPCRateStd = fltPCRateStd * 1.175;
> into
> fltPCRateStd = fltPCRateStd * 1.175F;
> to explicitly specify that the number 1.175 is of single precision.
> Floating point numbers defaults to be double precisioned.
>
> -- 
> Regards,
> Dennis JD Myrén
> Oslo Kodebureau
> "Mike P" <mrp@telcoelectronics.co.uk> wrote in message 
> news:uWspasTpEHA.324@TK2MSFTNGP11.phx.gbl...
>> Why does this cause the error 'cannot implicitly convert type 'double'
>> to 'float'?  Can you not multiply doubles by floats without converting
>> them all to the same datatype?
>>
>> fltPCRateStd = fltPCRateStd * 1.175;
>>
>>
>> Regards,
>>
>> Mike
>>
>>
>>
>> *** Sent via Developersdex http://www.developersdex.com ***
>> Don't just participate in USENET...get rewarded for it!
>
> 


Relevant Pages

  • Re: Explicit unsigned/signed conversion: ANSI/ISO rules?
    ... There is no semantic difference between implicit conversion and explicit ... If the signed char type has more than 8 value bits then the value in sc will ... representation when converting from signed char to unsigned char, ...
    (comp.lang.c)
  • Re: WP 6.x to Word conversion - bad results
    ... design-time. ... Dennis ... >> those) with a very ligh MN state seal behind text. ... >> problem is that upon conversion, ...
    (microsoft.public.word.conversions)
  • Re: Half hearted _Bool
    ... and anyone who is familiar enough with English to know what ... it denotes implicit conversion as anyone with good faith can ... If you substitute conversion for "cast" (as anyone with good faith can ...
    (comp.lang.c)
  • Re: srand(time(NULL))
    ... isn't there an implicit conversion to unsigned? ... But the conversion of a floating point value to an integral type ... Imagine that unsigned int is 32 bits, and time_t is a 64-bit integer ...
    (comp.lang.c)
  • Re: Justification for "->"?
    ... conversion of the function's name to a pointer value. ... implicit conversion, ... A function call is a primary expression followed by parentheses ...
    (comp.lang.c)