Example Code

Base number converters using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
This VI demonstrates how to convert between base 10 and base N numbers using unsigned integer arrays.

 

Description
Here is a brief description of the example:

"ConvertToBase.vi" takes a base 10 value and converts it into an array that represents the number in a differing base. From base^0 to base ^ i in length depending on how large the number is. This is achieved through iterative Quotient & Remainder operations, outputting the remainder into an auto indexed array, with the Quotient being passed through a shift register into the next iteration.

The math is based on the example found here: https://www.mathsisfun.com/base-conversion-method.html

"ConvertFromBaseTo10.vi" reverses the process and produces a base 10 integers from an array of base powers. This applies an iterative summation of the value of each index in the array multiplied by the base ^i value.

 

Requirements

  1. LabVIEW 2015 (or compatible)

 

Steps to Implement or Execute Code

  1. Recommended to use both subVIs together with "Convert to Base.vi" outputting to "Convert From Base To 10.vi" so that the format can be observed.
  2. Any further explanations required please ask in the comments.

Additional Information or References

VI Snippet

Convert From Base To 10.vi:

Convert From Base to 10 2015 NIVerified.png

Convert to Base.vi:

 Convert to Base 2015 NIVerified.png

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Certified LabVIEW Architect

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

Comments
PWoodward
NI Employee (retired)
on

For larger applications I would suggest taking out the property node in "ConvertFromBaseTo10.vi" as it can slow down processes with multiple iterations.

Certified LabVIEW Architect