Continuing the question, which was closed: C++: "auto" keyword affects math calculations?
As people suggested I modified the code by adding "f" suffix to floating-point values.
#include <cmath>
unsigned int nump=12u;
auto inner=2.5f;
auto outer=6.0f;
auto single=2.f*3.14159265359f/nump;
auto avg=0.5f*inner+0.5f*outer;
for (auto i=0u;i<nump;++i){
auto theta=i*single;
auto px=avg*sin(theta);
auto py=avg*cos(theta);
auto tw=17.f;
int v1=std::round(1.f+px-tw/2.0f);
int v2=std::round(2.f+py-tw/2.0f);
std::cout<<"#"<<i<<":"<<v1<<";"<<v2<<std::endl;
}
versus
#include <cmath>
unsigned int nump=12u;
float inner=2.5f;
float outer=6.0f;
float single=2.f*3.14159265359f/nump;
float avg=0.5f*inner+0.5f*outer;
for (unsigned int i=0u;i<nump;++i){
float theta=i*single;
float px=avg*sin(theta);
float py=avg*cos(theta);
float tw=17.f;
int v1=std::round(1.f+px-tw/2.0f);
int v2=std::round(2.f+py-tw/2.0f);
std::cout<<"#"<<i<<":"<<v1<<";"<<v2<<std::endl;
}
The result is exactly the same - output differs between two versions. So does it mean that "auto" always evaluates floating point value to "double" type?