Jump to content

round function


photo

Recommended Posts

Posted

Have unigine round function? In manual described only ceil and floor.

Posted

C++ have not round function too... It's XXI century... our space ships sail space of the Universe. Maybe it's time to add it in rank with ceil() and floor()? :)

Posted

float round(float val)
{
int mod = val * 10 % 5;
if(mod >= 5)
	val += 1.0f;
return floor(val);
}

 

is this what you want?

Posted

Fast round function for positive values:

int round(float value) {
  return int(value + 0.5f)
}

 

Round function for positive and negative values:

int round(float value) {
 if(value > 0.0f) return int(value + 0.5f);
 return int(value - 0.5f);
}

Posted

Yes, thanks. I find round function realization. I only was surprised, that Unigine have not round function implementation.

×
×
  • Create New...