[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printing floats/integer



This problem has been around about as long as computers I think.  I used
to have an old pascal routine that would tell you what format code you
needed for a given number, assuming you wanted to see the whole number,
but not anymore more than is necessary (for instance, 8.6).  Has anyone
written such a function for IDL?

You could probably piece together what you need using this function I just
found on the IDL Libraries Browser at Washington (see below).

Good luck,
Chris
;------------------------------------------------------------------
                function sigfig, range
;
;+
; NAME:
;       SIGFIG
;
; PURPOSE:
;       This function will return the number of significant figures in
;       the value "range"
;
; CATEGORY:
;       utilities
;
; CALLING SEQUENCE:
;       result = sigfig(range)

; INPUTS:
;       range = range for the significance, may be an array.
;
; OUTPUTS:
;       result = the number of significant figures expressed in base 10,
;               Example: sigfig(1000) = 3,
;                        sigfig(0.01) = -2
;
; COMMON BLOCKS:
;       none.
; SIDE EFFECTS:
;       none.
; MODIFICATION HISTORY:
;       Written by: Trevor Harris, Physics Dept., University of Adelaide,
;               July, 1990.