Download this file
1 2 3 4 5 6 7
;rounds x to n sig. figs. ;note: doesn't work with zero! function round_sf, x, n mag=floor(alog10(abs(x))) mult=10^(n-mag-1.) return, round(x*mult)/mult end