I have following code which that initialize a float vector:
std::vector<float> arr= { -11, -12, -45.3, -34.5, 110, 5, 10,3 ,22, 100, 1, 23 };
However I am get a compiling error:
error C2398: Element '3': conversion from 'double' to 'float' requires a narrowing conversion
If I change the third element -45.3 to -45 like following:
std::vector<float> arr= { -11, -12, -45, -34.5, 110, 5, 10,3 ,22, 100, 1, 23 };
The compilation is successful.
I am wondering where the problem is? Why -45.3 is not recognized as a float here? Because -34.5 is a similar case.
I am using Visual Studio 2015 and Windows 10.
Thanks.