AX / D365FO – num2Str Function

Converts a real number to a string.

str num2Str(
    real number,
    int character,
    int decimals,
    int separator1,
    int separator2)


numberThe real number to convert to a string.
characterThe minimum number of characters required in the text.
decimalsThe required number of decimal places.
separator1A DecimalSeparator enumeration value.
separator2A ThousandSeparator enumeration value.

Return Value

A string that represents the number.


For the decimals parameter, the maximum value is 16. If a larger number is used, this method instead obtains a value for the decimals parameter from the local computer. In both cases rounding does occur.

Possible enumeration values for the separator1 parameter are:

  • 1 – point (.)
  • 2 – comma (,)

Possible values for the separator2 parameter are:

  • 0 – no thousands separator
  • 1 – point (.)
  • 2 – comma (,)
  • 3 – space ( )


In the following code example, the first call to the num2str method provides 16 for the decimals parameter, and the second provides 17.

static void Job_Num2Str(Args _args)
        real realNum = 0.1294567890123456777; // 19 decimals places.
        info(Num2Str(realNum,0,16,1,3)); // 16 decimal places
        info(Num2Str(realNum,0,17,1,3)); // 17 decimal places


The messages are in the following Infolog output. The first number in the display contains 16 decimal place digits, whereas the second contains only 2.

Message (10:18:12)




Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di

Stai commentando usando il tuo account Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...