function strdigits,number,digits number=double(number) digits=round(digits) if digits gt 0 then begin number=double(round(number*(long64(10)^digits),/l64))/double((long64(10)^digits)) temp=strsplit(strcompress(string(number),/remove_all),'.',/extract) knowndigits=strlen(temp[1]) if digits le knowndigits then output=temp[0]+'.'+strmid(temp[1],0,digits) else output=temp[0]+'.'+temp[1]+strmid('0000000000000000000',0,digits-knowndigits) endif else begin number=long64(round(number/long64(10)^(-digits))*long64(10)^(-digits)) output=strcompress(string(number),/remove_all) endelse return,output end