[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printing floats/integer
What if I dont know that the float will
be 8 in length and has 6 decimals ??
How can we put this in a subroutine, that handles
a variable (e.g. PRO FORMAT, var1) and returns
the right way to print ??
For the int I use
PRO FORMAT, var
if (which eq 2) then begin
le=FLOOR(ALOG10(var)) + 1
RETURN, STRING(var, FORMAT='(I'+STRTRIM(STRING(le))+')'
endif else if (which eq 4) then begin
How do I do this for a float >>>??
1.22222200000 must become 1.22222 without leading or trailing spaces.
And in the best scenario 1.00 doesn;t become 1., but 1.0 ....
Klaus Scipal <firstname.lastname@example.org> schreef in berichtnieuws
> you can use the the string command in connection with format
> for example
> IDL> x=1.222221000000000000000
> IDL> print, string(format='(f8.6)',x)
> Sean Heukels <email@example.com> wrote in message
> > I wrote a small module for integers. The variable is formatted and
> > "1 " returns as "1"
> > Now this doesn't work with floats. for example if I want to print
> > I
> > dont want to see it as "1.222221000000000000000" or
> > "1.222222 "
> > Does anyone know how I can solve this ??
> > Greets Sean