L
Lars Amsel
Hi,
I am a bit confused about some C++ code
unsigned l = 1;
cout << -l << " " << pow(2., -l-1.) << endl;
I expected
$>-1 0.25
I got
$>4294967295 inf
OK. It's clear that their is a underflow in the unsigned l. I expected a
auto conversion by the compiler to int. When I change the code to
unsigned preL = 1;
int l = -preL;
cout << -l << " " << pow(2., -l-1.) << endl;
everything works fine. Is that well defined c++ behaviour or is it a bug
in g++ (version 3.3.x)?
Cheers
Lars
I am a bit confused about some C++ code
unsigned l = 1;
cout << -l << " " << pow(2., -l-1.) << endl;
I expected
$>-1 0.25
I got
$>4294967295 inf
OK. It's clear that their is a underflow in the unsigned l. I expected a
auto conversion by the compiler to int. When I change the code to
unsigned preL = 1;
int l = -preL;
cout << -l << " " << pow(2., -l-1.) << endl;
everything works fine. Is that well defined c++ behaviour or is it a bug
in g++ (version 3.3.x)?
Cheers
Lars