Knowledge Base

Return a decimal number from the head of the Rx buffer. Skip any leading spaces. Process leading + or – sign if present. Terminate on anything thereafter that’s not a decimal digit or decimal point, or after processing fw characters in total (including spaces, sign and decimal point). Consume the characters used but not the terminating character. Result in W, NaN if nothing there. R register signals outcome. 0 = OK, 1 = no valid decimal number present.

Notes:

  1. That this instruction will only process characters that have already been received. You should therefore ensure that either a known terminating character, or the required number of characters, have been received before attempting to execute this instruction.
  2. The character count fw includes leading spaces, signs and decimal point.
  3. The only characters removed from the buffer are leading spaces plus the characters that form the number. Hence, if a terminating character is encountered before fw characters are used, less than fw characters will be removed from the buffer.
  4. Conversion will end on the first unexpected character, including a trailing space, a second sign character or a second decimal point. This overrides the field width.
  5. The valid range for fw is 1 to 255. fw = 255 disables character counting.
  6. Anything more than 7 digits of input is meaningless, as the floating point number representation is only accurate to 6 or 7 decimal places. Excess digits will be nevertheless be consumed, up to the limits of fw.

Dialect exclusions: Not available in dialects before 26

See also ComRx_GetHex, ComRx_BufLen, ComRx_FindXInBuf

Examples

The following shows the result of the instruction ComRx_fGetNum 8 for various receive buffer contents. Underscores represent space characters

Receive buffer contents before (Shown as ASCII (printable) characters.Result returned in WReceive buffer contents after conversionComment
123.456xxxxxxxx123.456xxxxxxxxThe first x terminates conversion
123.456_xxxxxxxx123.456_xxxxxxxxThe trailing space terminates conversion. It is not consumed.
____123.456xxxx123456xxxxThe 4 leading spaces are counted in the field width. The decimal point “makes it”,
-123.456xxxxxxx-123.456xxxxxxxAll good, got it all
_-123.456xxxxxx-123.456xxxxxxxThe last digit is excluded, because the field width of 8 terminates conversion. Furthermore, a subsequent conversion (with I as-is) would return 6.
-12.3.456xxxxx-12.3.456xxxxxThe second decimal point terminates conversion. If the same instruction were executed again (with I as-is), it would return 0.456