# evaluating belzier curve, conversion error?

EDIT: I found an error in the factorial function and the combo, factorial and pow are all correct. Yet my curve is only correct for the first half that it is drawn. Do I have a problem assigning points?

I’m trying to simulate the bernstein polynomials for evaluating points on a belzier curve. however my problem is probably a conversion error and can be solved without understanding the program.

The combinatorial, factorial and pow functions work correctly I believe (or at least give realistice values), but when I add the polynomial products to the curve point (v->x, v->y), the vector always returns with a value of (-1.#INDO00, -1.#INDO00). It must be a conversion error. It gives me the warning conversion from ‘float’ to ‘unsigned int’, possible loss of data. any ideas?

Heres my code:

float factorial(float i) {
if (i <= 1)
return i;
return (i * factorial(i - 1));
}

float combonatorial(float n, float i){
float result = (factorial(n)/(factorial(i)*factorial(n-i)));
return result;
}

Vec eval_bezier ( float t, std::vector<Vec>& pnts ){
Vec *V = new Vec(0,0,0);
float n = (float)pnts.size();

``````for(float i = 0; i &lt; n; i++){
float ti = pow(t,i);
float tin = pow(1.0f -t, n-i);
float combo = combonatorial(n, i);

V-&gt;x += pnts[i].x*combo*ti*tin;   //warning: conversion from 'float' to 'unsigned int', possible loss of data
V-&gt;y += pnts[i].y*combo*ti*tin;  // warning: conversion from 'float' to 'unsigned int', possible loss of data
``````

}
return *V;

}