Reputation: 185
My function so called "inverzMatrika" returns an int type of variable. I need to convert it to a floating-point number. Any suggestions?
float inverz;
inverz = (float)(inverzMatrika(matrika));
Upvotes: 1
Views: 8672
Reputation: 107
You need not to worry about this conversion because it will be implicitly handled by the compiler. We don't lose data on conversion from int to float, hence no explicit type-casting tricks are required here.
Upvotes: -1
Reputation: 385
Try
double inverz;
inverz= (double )(inverzMatrika(matrika));
Or
float inverz = static_cast<float>(inverzMatrika(matrika));
Upvotes: 0
Reputation: 45470
use static_cast
, don't use C style cast
float inverz = static_cast<float>(inverzMatrika(matrika));
Upvotes: 2