1st COde :
Code:
#include<iostream.h>
#include<math.h>
int main(){
double d=log(8)/log(2);
cout<<"d="<<d<<"\t floor(d)="<<floor(d); //<<"\t"<<floor(10.0)<<"\n";
return 0;
}
2nd COde :
Code:
#include<iostream.h>
#include<math.h>
int main(){
double d=log(8)/log(2);
cout<<"d="<<d<<"\t floor(d)="<<floor(d)<<"\t"<<floor(10.0)<<"\n";
return 0;
}
Expected output : d=3 floor(d)=3 10
But The First code give : d=3 floor(d)=2 10
while the second gives the right output.
Could nyone plz explain whats going wrong!!
Nikhil

