Shop OBEX P1 Docs P2 Docs Learn Events
Conversion Formatters — Parallax Forums

Conversion Formatters

I am puzzled about the conversion formatters in the code listed at (https://www.parallax.com/sites/default/files/downloads/604-00060-MCP3202-Demo.bs2). My understanding is that the sample code creates a number up to 5000 to represent mV. However, the code displays the output in volts, so that requires the insertion of a decimal after the first digit. Here is the specific part:
  DEBUG HOME, CRSRXY, 11, 1, DEC mVolts0 DIG 3, ".", DEC3 mVolts0
I believe that DIG 3 only returns the most significant digit, but wouldn't the DEC3 display the same first digit again (plus the next two digits) after the decimal? That's where I am confused. Thanks

Comments

  • DIG 3 displays the 4th digit (counting from the right). DEC3 displays the lowest 3 digits. The DIG operator starts with 0 (lowest digit) up to 4 (highest digit).
  • Thanks, I believe I am following you. So for instance, would DEC1 return the least significant digit?
  • Yes, that's correct. And DEC2 would return the two least significant digits.
  • Ah, thank you.
Sign In or Register to comment.