SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

NUMBER TO STRING (LET)

Name:
    NUMBER TO STRING
Type:
    Let Subcommand
Purpose:
    Convert a parameter to a string where the number of digits will be controlled by the SET WRITE DECIMALS command.
Description:
    In some cases, it is desired to insert a number into a string or TEXT command with a specified number of digits. Typically, when the "^" operator is used to substitute the value of a parameter, trailing zeros will be truncated. This command allows you to copy the parameter to a string with more control over how the number is printed.

    Specifically, given the number 23.84 and the command

      SET WRITE DECIMALS <numdig>

    the parameter will be written in the following format to the string:

      <numdig> > 0 => Fy.x format (e.g., 23.840)
      <numdig> = 0 => Ix format (e.g., 23)
      <numdig> = -1 => blank string
      <numdig> = -3 to -20 => Ey.x format (e.g., 0.23840E+02)
      <numdig> = -99 => **
Syntax:
    LET <sout> = NUMBER TO STRING <a>
    where <a> is a parameter or number;
    and      <sout> is a string.

    Although you can enter an explicit number with this command, it is usually a parameter that is entered.

Examples:
    SET WRITE DECIMALS 2
    LET AVAL = 32.1
    LET SOUT = NUMBER TO STRING AVAL
Note:
    The SET PARAMETER EXPAND DIGITS command is an alternative method. This command controls how many digits are used for the substitution character ("^").

    Note that the SET PARAMETER EXPAND DIGITS command applies to all parameter substitions encountered. If this value is set to 0 or a positive integer, it will act similar to the NUMBER TO STRING command (i.e., F or I formats). However, it does not support exponential format.

    The SET PARAMETER EXPANSION command can be used to specify that parameter substitutions will be converted to exponential format. However, this is intended for the case when the parameters are being used in numerical computations. It does not generate the numbers in a format that is attractive for printing.

    In general, the SET PARAMETER EXPAND DIGITS and SET PARAMETER EXPANSION were developed in the context of using parameter substitution in numerical computations while the NUMBER TO STRING is intended for printing or display on plots.

Default:
    None
Synonyms:
    None
Related Commands: Applications:
    Data Management
Implementation Date:
    2015/06
Program:
     
    let a = 32.1
    let b = 0.2345/10**8
    set write decimal 2
    let sout1 = number to string a
    set write decimal -7
    let sout2 = number to string a
    let sout4 = number to string b
    set write decimal 0
    let sout3 = number to string a
    .
    crlf on
    move 50 80
    text A = ^sout1
    text A = ^sout2
    text A = ^sout3
    text B = ^sout4
    .
    move 50 30
    text A = ^a (default)
    set parameter expand digits 2
    text A = ^a (digits = 2)
    set parameter expand digits 0
    text A = ^a (digits = 0)
    set parameter expansion exponential
    text A = ^a (digits = exponential)
    text B = ^b (digits = exponential)
        
    plot generated by sample program

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 06/30/2015
Last updated: 06/30/2015

Please email comments on this WWW page to alan.heckert.gov.