I want to know if there is any difference in speed between the following two methods
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
float k=7;
float b=4;
cout<<(float)k/b<<" "<<endl;
cout<<(float)(k*powf(b,-1))<<" "<<endl;
return 0;
}
- trivial diivision
k/b - using multiplication
k*b^(-1),
I think that in second method, there is not actual division procedure. So I think the second is faster. Am I right?