ToBeReviewed/STRING/
strsci.pro
Given a number, returns a string of that B
number in scientific notation format ( e.g. A x 10 )
strsci
String
result = strsci(Data, Format=Format, POT_Only=POT_Only, MANTISSA_ONLY=MANTISSA_ONLY, SHORT=SHORT, TRIM=TRIM)
Parameters
Data
in
required
A floating point or integer number to be
converted into a power of 10.
Keywords
Format
default: '(f12.2)'
The format specification used in the string
conversion for the mantissa (i.e. the
"A" of "A x 10^B").
POT_Only
Will return only the "power of 10" part of the
string (i.e. the "10^B"). Default is to return
the entire string (e.g. "A x 10^B" )
MANTISSA_ONLY
return only mantissa of the string
SHORT
return 10^0 as '1' and 10^1 as '10'
TRIM
don't insert blanks (i.e. return Ax10^B)
Examples
Result = STRSCI( 2000000, format='(i1)' )
print, result
; 6
; prints 2 x 10!u6!n, which gets plotted as 2 x 10
Result = STRSCI( -0.0001 )
print, result
; 4
; prints -1.00 x 10!u-4!n, which gets plotted as 1.00 x 10
Result = STRSCI( 0d0, format='(f13.8)' )
print, result
;
; prints, 0.00000000
Version history
Version
$Id: strsci.pro 157 2006-08-21 09:01:50Z navarro $
History
bmy, 28 May 1998: VERSION 1.00 B
- now returns string of the form A x 10
mgs, 29 May 1998:
- bug fix: now allows negative numbers
- keyword MANTISSA_ONLY added
- default format changed to f12.2
bmy, 02 Jun 1998:
- renamed to STRSCI ("STRing SCIentific notation"),
mgs, 03 Jun 1998:
- added TRIM keyword
mgs, 22 Sep 1998:
- added SHORT keyword
- modified handling of TRIM keyword
mgs, 24 Sep 1998:
- bug fix with SHORT flag
bmy & mgs, 02 Jun 1999:
- now can handle DATA=0.0 correctly
- updated comments
mgs, 03 Jun 1999:
- can now also handle values lt 1 ;-)
- and doesn't choke on arrays
Known issues
Restrictions
This function does not "evaluate" the format statement thoroughly
which can result in somewhat quirky strings. Example:
print,strsci(-9.999) results in -10.0x10^0 instead of -1.0x10^1.
Need a better symbol than the 'x' for the multiplier...
Produced by IDLdoc 2.0 on Tue Aug 29 14:50:32 2006.