I'm trying to cast 2 integers into floats using static_cast
. The problem is that when I do the math I get 4 instead of 4.00.
Below I have made an example of the code.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int num = 4,
den = 1;
cout << static_cast<float>(num) / static_cast<float>(den);
}
If I'm doing it incorrectly,then please indicate where i am wrong. Also please mention if there is a way to get 4.00 instead of just 4?