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:

 > 0 => Fy.x format (e.g., 23.840) = 0 => Ix format (e.g., 23) = -1 => blank string = -3 to -20 => Ey.x format (e.g., 0.23840E+02) = -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:
 SUSBSTITUTE CHARACTER (^) = Substitute the value of a parameter or a string. CONCATENATE CHARACTER (&) = Concatenate two strings. CHARACTER = Convert numeric values to strings based on the ASCII collating sequence. ICHAR = Convert a string to numeric values based on the ASCII collating sequence. LET STRING = Defines a string. SUBTRING = Extract a substring from an existing string. STRING INDEX = Extract the start/stop positions of a substring within a string. STRING CONCATENATE = Concatenate one or more previously defined strings. STRING EDIT = Edit a string. STRING MERGE = Insert a string into another string without overwrite. STRING LENGTH = Return the length of a string. STRING REPLACE = Insert a string into another string with overwrite. UPPER CASE = Convert a string to upper case. LOWER CASE = Convert a string to lower case. GROUP LABEL = Define the text for group labels.
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)


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

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