Mathematical and algorithmic operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Mathematical and algorithmic operations >

Mathematical and algorithmic operations

VTN. - Variable To Numeric (Decimal)

Previous Top Next


MiniRobotLanguage (MRL)

 

VTN. Command

Variable To Numeric (Dezimal)

 

 

Intention

 

Convert a numeric value into the Decimal number-System, optional you can specify the length of the output string.

 

This very simple example

 

$$NUM=&B10011111111111110001

VTN.$$NUM

DBP.$$NUM

 

Will give the result: "655345"

 

In this example we say that we want the output to be formatted to 15 digits.

 

$$NUM=&H09FFF1

VTN.$$NUM||15

DBP.$$NUM

ENR.

 

Therefore the result is "000000000655345"

 

In both cases, we did not specify P2 (Target variable, therefore the result was placed in the source variable.

 

For details on how to prefix Hexadecimal, Octal or Binary numbers, see

3.5 Hexadezimal, Decimal and Binary and more

 

 

 

 

Syntax

 

VTN.P1[|P2][|P3]

 

 

Parameter Explanation

 

P1 - Variable containing any NUM

 

P2 - (optional) Variable for the result, if omitted result is been stored in Source variable.

 

P3 - (optional) optional, value that is used as a fix length of the output string.

      Empty places are filled with "0"'s.

      If you specify less digits then needed, the number will be clipped from the right side,

 

      Example:

      $$NUM=655345

     VTN.$$NUM|$$TAR|2

 

   will give you "45" as result (instead of 655345)

 

 

 

Example

 

'*****************************************************

' EXAMPLE 1:

'*****************************************************

' Binary to hexadecimal

$$NUM=&B10011111111111110001

VTH.$$NUM

DBP.$$NUM

 

' Hexadecimal to decimal (unsigned)

$$NUM=&H0$$NUM

VTN.$$NUM|$$TAR|6

DBP.$$TAR

ENR.

 

 

 

Remarks

 

Please always use the proper prefix for non-decimal numbers.

More details on this, see here:

3.5 Hexadezimal, Decimal and Binary and more

 

 

 

Limitations:

 

-

 

 

See also:

 

    3.5 Hexadezimal, Decimal and Binary and more

    VTH. - Variable to Hexadecimal

    VDC. - Variable Decrement

    CAL. - mathematical CALculation

    VAR. - Variable Set Value/Clear

    VAN. - Variable Numeric