Re: cast reference argument
Thanks for all of the replies.
Carl, Abdo, Alex
1) The values that I mentioned in my original post were from the VC2003
watch window for the posted toy example, and I unfortunately thought the
watch window was correct. Thanks for straightening me out.
All,
2) There actual code, which called a function much more involved than this,
returned the V2 value to another function (instead of printing it.) V2 came
back incorrect, while the V1 type of line came back fine. I think that this
was caused by a separate issue (1.#INF0000...) from an underflow in the
routine - I actually got different values in debug versus release modes.
Correcting the underflow, removed the difference between V1 and V2 - go
figure? I guess I went down the wrong path because I believed the watch
window - even in the toy example. Since I'm an old Fortran programmer, I
should have printed the value first thing!
Thanks to all.
--
Steve
"Hendrik Schober" wrote:
Steve <Steve@discussions.microsoft.com> wrote:
Is this correct behavior? In the code below (Visual Studio .NET 2003 (debug
mode)), lcount becomes 100.0 (good), but (double)count is some type of
garbage number (like 1234424) (bad), so v1 and v2 get very different results
(v1 correct, v2 wrong.)
[...]
This
#include <iostream>
void doit(int& count)
{
count = 100;
double lcount = (double)count;
double v1 = 10.0/lcount;
double v2 = 10.0/((double)count);
std::cout << v1 << ", " << v2 << std::endl;
}
int main()
{
int count = 0;
doit(count);
return count;
}
works as expected for me using VS2003.
HTH,
Schobi
--
SpamTrap@gmx.de is never read
I'm Schobi at suespammers dot org
"The sarcasm is mightier than the sword."
Eric Jarvis