This is a utility routine format a number into a string. It is used primarily for formatting numbers that will appear in text widgets in widget programs.
A string with the formatted number or numbers is returned.
- number in required
The number to be turned into a string. May be any data type except complex, double complex, pointer or object. May be an array of numbers.
- DECIMALS in optional type=integer default=2
Set this keyword to the number of decimal places to be included to the right of the decimal point in floats and doubles. Set to 2 by default. In numbers with absolute values between 0 and 1, the number of decimals is equivalent to the number of significant digits. See the example below.
Here is how to use this program:
IDL> array = [45.123456, -30.123456, !Values.F_Nan, !Values.F_Infinity, $ 0.00123456, -0.00123456, 0.0123456, 0.123456, 1.234567] IDL> FOR j=0,N_Elements(array)-1 DO Print, Number_Formatter(array[j], Decimals=4) 45.1235 -30.1235 NaN Inf 0.001235 -0.001235 0.01235 0.1235 1.2346
FANNING SOFTWARE CONSULTING:
David W. Fanning 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: email@example.com Coyote's Guide to IDL Programming: http://www.idlcoyote.com
Copyright (c) 2012, Fanning Software Consulting, Inc.
Written, 8 November 2012 by David W. Fanning from the retired Number_Formatter program. The algorithm I was using for numbers between 0 and 1 used a LT in the Where function to find an index. It appears this should have been a LE, instead. 11 Jan 2013. DWF.
|Modification date:||Fri Mar 27 11:07:38 2015|