正在加载图片...
20.6 Arithmetic at Arbitrary Precision 917 for(j=n;j>=1;j-){ ireg=u[i]+HIBYTE(ireg); w[j+1]-LOBYTE(ireg); w[1]-HIBYTE(ireg); void mpsmu(unsigned char w,unsigned char un],int n,int iv) Short multiplication:the unsigned radix 256 integer u[1..n]is multiplied by the integer iv (in the range0≤iv≤255,yielding w[1.n+i] int j; unsigned short ireg=0; for(j=nj>=1;j--){ 83 ireg=u[j]*iv+HIBYTE(ireg); w[j+1]=LOBYTE(ireg); 11600 (including this one) granted for w[1]-HIBYTE(ireg) void mpsdv(unsigned char w[],unsigned char u[],int n,int iv,int *ir) to any Short division:the unsigned radix 256 integer u[1..n]is divided by the integer iv (in the by Cambridge University Press. tusers to make one paper from NUMERICAL RECIPES IN C: 19881992 range0≤iv≤255),yielding a quotient w[1..n]and a remainder ir(with0≤ir≤255). int i,j; (North America server computer, THE *1r=0; ART for (j=1;j<=n;j++){ 1=256*(*ir)+u[j]; w[j]=(unsigned char)(i/iv); Programs wirsi iv; void mpneg(unsigned char un],int n) Ones-complement negate the unsigned radix 256 integer u[1..n]. int ji unsigned short ireg=256; for (j=n;j>=1;j--){ ireg=255-u[j]+HIBYTE(ireg); only),orsend email to directcustserv@cambridge.org u[i]=LOBYTE(ireg); 1988-1992 by Numerical Recipes OF SCIENTIFIC COMPUTING(ISBN 0-521-43108-5) void mpmov(unsigned char u[],unsigned char v],int n) Move v[1..n]onto u[1..n]. int j; (outside North America) Software. for (j=1;j<=n;j++)u[j]=v[j]; void mplsh(unsigned char u[],int n) Left shift u(2..n+1)onto u[1..n]. int j; for(j=1;j<=n;j++)u[j]=u[j+1];20.6 Arithmetic at Arbitrary Precision 917 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). for (j=n;j>=1;j--) { ireg=u[j]+HIBYTE(ireg); w[j+1]=LOBYTE(ireg); } w[1]=HIBYTE(ireg); } void mpsmu(unsigned char w[], unsigned char u[], int n, int iv) Short multiplication: the unsigned radix 256 integer u[1..n] is multiplied by the integer iv (in the range 0 ≤ iv ≤ 255), yielding w[1..n+1]. { int j; unsigned short ireg=0; for (j=n;j>=1;j--) { ireg=u[j]*iv+HIBYTE(ireg); w[j+1]=LOBYTE(ireg); } w[1]=HIBYTE(ireg); } void mpsdv(unsigned char w[], unsigned char u[], int n, int iv, int *ir) Short division: the unsigned radix 256 integer u[1..n] is divided by the integer iv (in the range 0 ≤ iv ≤ 255), yielding a quotient w[1..n] and a remainder ir (with 0 ≤ ir ≤ 255). { int i,j; *ir=0; for (j=1;j<=n;j++) { i=256*(*ir)+u[j]; w[j]=(unsigned char) (i/iv); *ir=i % iv; } } void mpneg(unsigned char u[], int n) Ones-complement negate the unsigned radix 256 integer u[1..n]. { int j; unsigned short ireg=256; for (j=n;j>=1;j--) { ireg=255-u[j]+HIBYTE(ireg); u[j]=LOBYTE(ireg); } } void mpmov(unsigned char u[], unsigned char v[], int n) Move v[1..n] onto u[1..n]. { int j; for (j=1;j<=n;j++) u[j]=v[j]; } void mplsh(unsigned char u[], int n) Left shift u(2..n+1) onto u[1..n]. { int j; for (j=1;j<=n;j++) u[j]=u[j+1]; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有