Regarding Basic Concept

@@@@@@@@@@@@@
while(num != 0)
{
pos ++ ;
num = num / 2 ;
}
pos - - ;
@@@@@@@@@@@@@

If I use above code for determining pos , I am getting AC .
And if I use below code for determining pos , I am getting WA .

@@@@@@@@@@@@@@@
pos = floor( log 2 ( num ) );
@@@@@@@@@@@@@@@

Range of num : 1 <= num <= 10^18

Code for WA

Code for AC

5 Likes

log function returns float/double, hence it might have precision errors.
Try to avoid it if possible.