#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
typedef double real;
int main (int argc, const char * argv[])
{
struct Vert { real x, y; };
real n = 2;
Vert v = {0, 1};
for(int i = 0; i < 550; i++){
real sideLength = sqrt((v.x - 1) * (v.x - 1) + v.y * v.y);
cout << setprecision(30) << sideLength * n << endl;
n *= 2;
v.x = (v.x + 1) / 2;
v.y = v.y / 2;
real norm = sqrt(v.x * v.x + v.y * v.y);
v.x /= norm;
v.y /= norm;
}
return 0;
}
With float it breaks much earlier. (Change the real typedef to change the type across the code)