round.h

来自「g729 coding ipaddressing」· C头文件 代码 · 共 26 行

H
26
字号
/* This routine takes in a floating point number and rounds it to */
/* the nearest integer. 										  */

#ifdef ROUNDFUNC
static int round(float afloat)
{
int rounded_int;

  /* this will truncate afloat */
  rounded_int = afloat;
  /* positive and negative numbers are handled differently */
  if (afloat < 0) 
  {
	/* if the fractional part is -.5 or less round down */
	if (afloat - rounded_int <= -.5) rounded_int--;
  }
  else
  {
	/* if the fractional part is .5 or greater round up */
	if (afloat - rounded_int >= .5) rounded_int++;
  }    
	
  return(rounded_int);
}
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?