Example Code

Digit Extractor.vi

Code and Documents

Attachment

Overview

This VI contains 2 examples of how to extract the digits from an integer. I found this useful when trying the Vampire Numbers challenge and other number analysis applications.

Description

This VI uses two different methods to break an integer into a numeric array of its digits.  The first method divides by decreasing factors of 10 and outputs the quotients in an array.  The second method converts the integer to a string, removes characters from the string and converts the resulting array back into integers.

Steps to Implement or Execute Code

  1. Input the integer you want to extract digits from.
  2. Run the VI.
  3. Observe the results of the two different methods in the output arrays.

Requirements

Software

LabVIEW 2010 or later

Hardware

None

**This document has been updated to meet the current required format for the NI Code Exchange. For more details visit this discussion thread**

National Instruments - Tech Support

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors