/****** Significant Digits *********************** Author: Cameron Rookley http://www.goodnet.com/~dh74673/home.htm Date: 20 July 1999 This code is provided gratis, without performance warrantee, for private non-commercial use. Here is a proc (scroll down) with some test code to round a vector x to d significant digits, where d is conformable with x. syntax: newvalues=siground(oldvalues,numsigdigs); ****************************************************/ /* test code */ new; cls; x=1511.36|313.245|(-42.324)|(-0.2254)|(-0.00032546); d=3|2|4|2|5; newx=siground(x,d); print x~newx; stop; proc(1)=siground(x,d); local scfactor,newx; /* first get scale factor */ scfactor=floor(ln(abs(x))./ln(10)); newx=(x.*(10.^(-scfactor))); newx=round(newx.*(10.^(d-1)))./(10.^(d-1)); newx=newx.*(10.^scfactor); retp(newx); endp;