str

  • Austin C Bullock

interface str

Description: Function for returning a character representation of a number.

To return the empty string, use no arguments:

result = str()

For x a scalar of type String:

result = str(x)

This is for scalar String to character conversion.

For x a scalar of type integer:

result = str(x [, fmt])
  • fmt is optional, may be one of INT_FMTS

For x a scalar of type real:

result = str(x [, locale, fmt, decimals])
  • locale is optional, may be one of LOCALES
  • fmt is optional, may be one of REAL_FMTS
  • decimals is optional and of type integer

For x a scalar of type complex:

result = str(x [, locale, fmt, decimals, im])
  • locale is optional, may be one of LOCALES
  • fmt is optional, may be one of REAL_FMTS
  • decimals is optional and of type integer
  • im is optional and of type character(len=*)

Note

Note that str operates on scalars only. For elemental functionality, see String.

Optional Arguments

Integer formats (default is "i"):

INT_FMTS = [ "i", "z" ]

Real formats (default is "e"):

REAL_FMTS = [ "e", "f", "z" ]

Locales (default is "US"):

LOCALES = [ "US", "EU" ]

Decimals: decimals specifies the number of digits on the rhs of the radix point, with a default determined internally based on the text format and precision.

Imaginary unit: im specifies the form of a complex number. By default, complex numbers will be written as ordered pairs, e.g. (2.45,3.45). If im is specified, then the number will be written as a sum with the specified imaginary unit, e.g. 2.45+3.45j for im="j" or 2.45+3.45*1i for im="*1i".