xfmod.c

来自「数值算法库」· C语言 代码 · 共 29 行

C
29
字号
/*  xfmod.c    CCM mathematics library source code. * *  Copyright (C)  2000   Daniel A. Atkinson    All rights reserved. *  This code may be redistributed under the terms of the GNU general *  public license. ( See the gpl.license file for details.) * ------------------------------------------------------------------------ */#include "xpre.h"struct xpr xfmod(s,t,p)struct xpr s,t; int *p;{ struct xpr h; unsigned short *q,*ph; short k;  h=xdiv(s,t); ph=(unsigned short *)&h; k=(*ph&m_exp)-bias;  if(k>=0){ rshift(31-k,ph+1,2);    q=(unsigned short *)p;    *(q+1)= *(ph+1); *q= *(ph+2);   }  else *p=0;  if(*p){ if(*ph&m_sgn) s=xadd(s,xmul(t,inttox(*p)),0);          else s=xadd(s,xmul(t,inttox(*p)),1);   }  return s;}struct xpr xfrex(s,p)struct xpr s; int *p;{ unsigned short *ps=(unsigned short *)&s,u;  *p=(*ps&m_exp)-bias+1; u= *ps&m_sgn;  *ps=bias-1; *ps|=u; return s;}

⌨️ 快捷键说明

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