<<prev file | next file >>    view single page | view frames    summary: fields | routine    details: routine

ToBeReviewed/STRING/

strsci.pro

Given a number, returns a string of that B number in scientific notation format ( e.g. A x 10 )

topstrsci 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 325 2007-12-06 10:04:53Z pinsard $ Copyright (C) 1998, 1999 Bob Yantosca and Martin Schultz, Harvard University This software is provided as is without any warranty whatsoever. It may be freely used, copied or distributed for non-commercial purposes. This copyright notice must be kept with any copy of this software. If this software shall be used commercially or sold as part of a larger package, please contact the author to arrange payment. Bugs and comments should be directed to bmy@io.harvard.edu or mgs@io.harvard.edu with subject "IDL routine strsci"

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...

Statistics

McCabe cyclic 15
McCabe essential 1
McCabe modular design 1
Produced by IDLdoc 2.0.