Using Exponents in Netlinx Code
Technical Support Guide
Brand:
- AMX
Models:
- Netlinx
Overview:
According to Netlinx Studio Help, the following is an example of exponent usage:
Float Num
Num = ATOF('The total = -1.25e-3') // Num = -0.00125Notice how the exponent value is contained in a char or ascii value. The “the total=" portion is irrelevant - The statement above, for clarity's sake, should actually read:
Num = ATOF(' -1.25e-3') // Num = -0.00125In order to manipulate any of these values we must break the statement into its variable components, which is the base number, in this case the -1, the decimal, .25, and the exponent, -3.
These are the values that will vary.
When we parse feedback or generate a button event to change one of these values, the value has to be again saved as a char variable and substituted back into the ATOF (ascii to float) statement to produce a numeric output.
In our code, we need to build a statement as follows.
Outputvariable=ATOF(“BaseNumberVariable,'.',DecimalVariable,'e',ExponentVariable)Please see the example function and button events in the downloadable sample code. Notice in the function there is one variable to indicate which value to change, and the other variable is the value itself. The button events simply increment and decrement values.
Download: