Re: question(s) about declaring variables




"Michael C" <mculley@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%2374euN2eFHA.2244@xxxxxxxxxxxxxxxxxxxxxxx
> "spacewarp" <sureshsitaula@xxxxxxxxx> wrote in message
> news:1119851711.614989.110510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> One question, Michael : Are 1000& and CLng(1000) exactly the same?
>>
>> I mean, doesn't the latter come at a slight performance loss of calling
>> a function and the associated conversion of an integer to a long value?
>> Or is CLng(1000) directly evaluated as 1000& during compilation?
>
> They compile to the exact same assembly code so no performance hit at all.

I have to question that. Any performance hit would indeed be minimal (if
existant, or at least measureable, at all), but I don't think they'd compile
exactly the same. It's two different things. One is type-casting a literal
value to a specific data type and this occurs at compile time. Another is
*converting* a literal value from one data type to a different data type and
this occurs at runtime (and subsequently happens every time the code is
executed).

I really think you're mistaken. I don't see how they can compile
identically.

--
Mike
Microsoft MVP Visual Basic


.



Relevant Pages

  • Re: WG: SI Units - has Ada missed the boat?
    ... I don't remember the details but there was also a way to define the conversion from various units into the generic _UNITS. ... This program would then write the ADA specs and bodies for the conversion. ... The "UNITS" package took about 4 hours to compile and every component took a long time to compile because every expression had to be compared to the myriad of overloads to determine if the expression was valid. ... myint: INTEGER; ...
    (comp.lang.ada)
  • Re: Microsoft Losing Interest in C#?
    ... > The code doesn't compile right now because, IIRC, the JCLA generated a few ... > javaisms in the sections where a direct conversion wasn't possible. ... The JLCA doesn't understand the Comparable interface, ... UUID.cs: error CS0246: The type or namespace name 'MessageFormat' ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [ANNOUNCE] high-res-timers patches for 2.6.6
    ... but all are compile in. ... >>I would have to redo the conversion code. ... can, at boot time, switch to one of the standard clocks and thus disable HRT (or ... I had not considered not using the APIC timer if it was available. ...
    (Linux-Kernel)
  • 50 years of progress in the language
    ... almost every program would compile and run correctly using ... Smaller length alphabetic test onstant strings were treated as ... Conversion between integer variabless and equivalent digit strings ... the character array and the character string. ...
    (comp.lang.fortran)
  • Re: fast and accurate in mixed mode operations
    ... < double using the command dble() in the expressions or would it be ... For the same conversion, the speed and accuracy should be ... precision, then you might need a conversion function. ... There used to be questions about constant conversion at compile ...
    (comp.lang.fortran)

Loading