Numbers bigger then 10 to a array of integers

Okay I want to do the following...
I have a number (bigger then 10). Assume I got the number 4327 now I want to change this number to a numeric array with the values [4,3,2,7] as fast as possible.
I only thought of one solutions (which is possible also the fastest), but I want to know if anyone has maybe a better idea.
My solution is just to cast that number to a string using the NumberToString VI, "4327", then split into a array of strings ["4","3","2","7"], and cast it back using the StringToNumber VI.
Anyone got a better faster idea?
Solved!
Go to Solution.

Jeff Bohrer wrote:
Absolutely not!
Although Nathand's solution could be expanded to work with any base as well. This may be a bit faster
the use of native recursion vs the buffer expansion should show in favor of the recusive technique up to a considerable number of digits.
Nowhere close, unfortunately.  Here's the benchmarking VI updated with your code, which is 4-5x slower than both my approach and Matt W's.  The recursive implementation is a good idea but LabVIEW's recursion is not terribly efficient.  Each recursive copy requires allocating an entirely new copy of the VI.
EDIT: uploaded recursive subVI, needed as well.
Attachments:
benchmark to individual digits.vi ‏15 KB
Recurse.vi ‏9 KB

Similar Messages

  • Array of Integers please help?

    pleace can someone help me? i am new in java . i want to create an array integers? Here i hava my codes that creates an array of strings? can anybody convert that so can accept integer and modified my method to add Integers instead of strings?Thanks for your time
    public class Numbers implements Serializable {
    * A constant: The maximum number of Random numbers
    // static public int MAXSETS = 3;
    static public final int MAXSETS = 3;
    * The integer variable count will hold the number of states in the subset
    private int count = 0;
    * The array state will hold the States in the subset of states
    private String number[] = new String[MAXSETS];
    * Constructor method: Reserve space for the 50 Integers
    public Numbers() {
    for(int i=0;i < MAXSETS;i++) {
    number = new String();
    * addNumbers: adds a number to the collection of Numbers
    * a string with the new number is passed as a parameter
    public void addNumbers(String newNumber) {
    number[count] = newNumber;
    count++;
    // System.out.println("scdsddfs"+ state);
    * toString: Convert the object to a string
    public String toString() {
    // int num;
    String str = count + " ";
    for(int i=0;i < count;i++){
    // num = Integer.parseInt(str);
    str = number;
    // str = str+" "+number;
    // System.out.println("scdsddfs"+ str);
    return str;

    pleace can someone help me? i am new in java . i want
    to create an array integers? Here i hava my codes that
    creates an array of strings? can anybody convert that
    so can accept integer and modified my method to add
    Integers instead of strings?Thanks for your time[snip]
    You create an array of integers by saying
    int[] myArrayOfIntegers[SIZE_I_WANT];To convert a String to an int, use the Integer.parseInt method.
    Good luck
    Lee

  • How to add an array of integers to JList?

    I know it should be easy, but I can't see a simple way to add an array of integers to a JList.
    int[] per_ints = tempbean.getPercents();
    //missing wrapper
    JList list2 = new JList(per_ints);//wont work because JList will not take int[]

    what you should do is convert the int to string and then populate the list...
    int[] per_ints = tempbean.getPercents();
    Integer perI[] = new Integer[per_ints.length];
    for (int z = 0; z< per_ints.length; z++){   
    perI[z] = new Integer(per_ints[z]);
    JList list2 = new JList(Integer.toString(perI));
    i think this should work...but if not try to convert tempbean.getPercent() to string and making that array a string array...basically store string in the list some how....probably not the best or simplest way..but i think it should work

  • Creating colour image map from an array of integers

    not really that relvant to swing, or in fact java even but i wasnt sure where to ask it so:
    i have an array of integers that represents information about each pixel in an image. i.e. for every pixel there is an integer value.
    at the moment i create another image from a quantised version of these integer values, which gives me a greyscale image, where black is low intensity info and white is high.
    however what i want to do is create a colour image like you see, for example, on weather forecasts. where low intensity info is blue, then purple, then red, orange, yellow and then white being the highest.
    i need some kind of algorithm that does this. does anybody have some code that does this already?
    thanks
    kevin

    sorry for not replying sooner sniper. thanks for your help but i have solved the problem:
    thanks to my mate marc for the code.
    import java.awt.Color;
    /** Class to assist in assigning color to a mathematical value.
    *  Data values must be normalized.
    *  @author Marc Ramsdale
    *  Written 20th August 2003
    public class ColorScale {
         /** Receives a normalized value (between 0.0 - 1.0)
          *  The constructor then creates a colour according
          *  to the selected colour scale.
          *  If value is outside range 0.0 - 1.0 colour is java.awt.Color.BLACK
          *  @param double value - (between 0.0 - 1.0)
         /** Maps the normalized value to a color
          *      BLUE      *
          * GREEN    *      *
          * RED           *
         public static Color generateColour(double value) {
          double red = 0.0;
          double green = 0.0;
          double blue = 0.0;
          Color color;
          int gradient = 4;
          int offset1 = 2;
          int offset2 = 4;
              if((value >= 0.0) && (value < 0.25)) {
                   red = 0.0;
                   green = value * gradient;
                   blue = 1.0;               
              else if((value >= 0.25) && (value < 0.5)) {
                   red = 0.0;
                   green = 1.0;
                   blue = -(value * gradient) + offset1;
              else if((value >= 0.5) && (value < 0.75)) {
                   red = (value * gradient) - offset1;
                   green = 1.0;
                   blue = 0.0;
              else if((value >= 0.75) && (value <= 1.0)) {
                   red = 1.0;
                   green = -(value * gradient) + offset2;
                   blue = 0.0;
              return new Color((float)(red), (float)(green), (float)(blue));

  • Java - Instance variable that can reference an array of integers?

    Hello,
    I have the following question in my assignment:
    Your first task is to declare a private instance variable called cGroups that can
    reference an array of integers. You should then write a constructor for GameN. This should
    take a suitable array as its argument which should be used to initialise cGroups.
    In order to test your code for declaring and initialising cGroups, you should execute
    the following code
    int[] coin = {2, 8, 5};
    GameN aGame;
    aGame = new GameN(coins);
    and I have complete the code below but it's not working. maybe I'm reading it wrong or
    not understandin something. Could someone correct it? or put me on the right lines
    private int[] cGroups = new int[]
    public GameN(int group1, int group2, int group3)
    super();
    this.cGroups = {group1, group2, group3};
    }

    ShockUK wrote:
    I've changed it to
    private int[] coinGroups = new int[] {1};
    public Nim(int group1, int group2, int group3)
    super();
    int[] coinGroups = {group1, group2, group3};
    }But I still get the same error "Constructor error: Can't find constructor: Nim( [I ) in class: Nim"
    Look at the line that error is pointing at. You're trying to use a constructor that doesn't exist. This is not a problem with creating an array.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Best way of saving an array of integers to use later?

    I am having trouble figuring out where to initialize an array of integers so it is available everywhere. It's just a simple array of integers to be used as indices into another array. So I figured an ordinary C array like this is sufficient:
    int arrayOfIndices[] = {3, 11, 12, 25, 26, 43, 50, 53, 58, 59, 62, 76, 77, 81, 94, 95, 110, 113, 114, 117, 118, 123, 136, 152};
    It's ok to just use an ordinary C array for this, right? It seems that it is much harder to initialize a similar NSArray of integers. Or is there an easy way to do that?
    One problem I'm having is I'm having trouble figure out where to stick the above array so that it is usable through the program. With my NSArray objects I've been defining them in the interface, then initializing them in viewDidLoad with retain.
    Is there something analogous I can do with ordinary C int arrays? Or, alternatively, an easy way to initialize an NSArray of integers so I can deal with them like I do with other NSArrays?
    Thanks,
    doug

    Never mind. It looks like just not putting anything in the interface file and sticking the definition of the C int array at the top of my implementation file where I import files and define some other stuff works fine.
    doug

  • Passing an array of integers to a method...

    here's the case, i have 2 array of integers parent and child. how can i pass the arrays in a method so i can evaluate the contents of both arrays?
    here's the block of the code that contains what i'm talking about.
    for(int i=0; i<tree.length; i++) {//separate child from parent      
         int[] parent = new int[(tree.length()/2)];
         int[] child = new int[(tree[i].length()/2)];
         for(int j=0, ctr=0; j<tree[i].length(); j++, ctr++) {               
              parent[ctr] = Integer.parseInt(Character.toString(tree[i].charAt(j))); //get the parents
              j++;
              child[ctr] = Integer.parseInt(Character.toString(tree[i].charAt(j))); //get the children
         if(isTree(parent, child)) //evaluate if case is a tree
         System.out.println("Is a tree");
         else
         System.out.println("Is not a tree");
    }//separate child fronm parent     

    geez, thanks... adding "static" did work.. >_< my bad, i'm new in java... and i'm sorry for calling you
    "sir", thanks a lot monica... ^^ by the way, it's 1:00 pm here asia.I'm glad it worked--do you understand what "static" means here?
    No problem about the "sir". I usually use "he" myself, if I don't know whether it should be he/she. And, around here on the forum (and software engineers at most companies), there are certainly more men than women. People tend to look at MLRon and assume my name is "Ron", but that's my last name. :)
    You don't need to call people "sir" or "ma'am" here. Just names or screen names (like MLRon) will do. :)
    Have a nice afternoon, then!

  • Constructing a linked list from an array of integers

    How do I create a linked list from an array of 28 integers in a constructor? The array of integers can be of any value that we desire. However we must use that array to test and debug methods such as getFirst(), getLast(), etc...
    I also have a method int getPosition(int position) where its suppose to return an element at the specified position. However, I get an error that says cannot find symbol: variable data or method next()
    public int getPosition(int position){
         LinkedListIterator iter=new LinkedListIterator();
         Node previous=null;
         Node current=first;
         if(position==0)
         return current.data;
         while(iter.hasMore()){
         iter.next();
         if(position==1)
         return iter.data;
         iter.next();
         if(position==2)
         return iter.data;
         iter.next();
         if(position==3)
         return iter.data;
         iter.next();
         if(position==4)
         return iter.data;
         iter.next();
         if(position==5)
         return iter.data;
         iter.next();
         if(position==6)
         return iter.data;
         iter.next();
         if(position==7)
         return iter.data;
         iter.next();
         if(position==8)
         return iter.data;
         iter.next();
         if(position==9)
         return iter.data;
         iter.next();
         if(position==10)
         return iter.data;
         iter.next();
         if(position==11)
         return iter.data;
         iter.next();
         if(position==12)
         return iter.data;
         iter.next();
         if(position==13)
         return iter.data;
         iter.next();
         if(position==14)
         return iter.data;
         iter.next();
         if(position==15)
         return iter.data;
         iter.next();
         if(position==16)
         return iter.data;
         iter.next();
         if(position==17)
         return iter.data;
         iter.next();
         if(position==18)
         return iter.data;
         iter.next();
         if(position==19)
         return iter.data;
         iter.next();
         if(position==20)
         return iter.data;
         iter.next();
         if(position==21)
         return iter.data;
         iter.next();
         if(position==22)
         return iter.data;
         iter.next();
         if(position==23)
         return iter.data;
         iter.next();
         if(position==24)
         return iter.data;
         iter.next();
         if(position==25)
         return iter.data;
         iter.next();
         if(position==26)
         return iter.data;
         iter.next();
         if(position==27)
         return iter.data;
         iter.next();
         if(position==28)
         return iter.data;
         if(position>28 || position<0)
         throw new NoSuchElementException();
         }

    How do I create a linked list from an array of 28 integers
    in a constructor? In a LinkedList constructor? If you check the LinkedList class (google 'java LinkedList'), there is no constructor that accepts an integer array.
    In a constructor of your own class? Use a for loop to step through your array and use the LinkedList add() method to add the elements of your array to your LinkedList.
    I get an error that
    says cannot find symbol: variable data or method
    next()If you look at the LinkedListIterator class (google, wait for it...."java LinkedListIterator"), you will see there is no next() method. Instead, you typically do the following to get an iterator:
    LinkedList myLL = new LinkedList();
    Iterator iter = myLL.iterator();
    The Iterator class has a next() method.

  • Using a checkbox in numbers- if,then, I want to display today's date if checked, and keep that date, the day it was checked, not the current day

    Using a checkbox in numbers- if,then, I want to display today's date if checked, and keep that date, the day it was checked, not the current day

    this will not work.  Numbers does not provide a timestamp.  you can, however, enter the formula "=now()" in any cell, then copy that same cell, then paste (using the command "Edit > Paste Formula Results"
    If you need a time stamp often,
    make a single cell table with the formula (mentioned earlier).
    and copy and paste as needed

  • How do i make a collage bigger then 300mm x 300mm thats all it lets me do

    I'm trying to make a collage bigger then 300mm x 300mm as it wont let me go any bigger and i would like to go bigger and i don't know how?

    Although Dreamweaver Templates and Library items are suitable tools for doing this, they're tedious and cumbersome at best. They get old very quickly.
    By far the most efficient method is to set your navigation bar up as a Server Side Include (SSI).
    SSIs are not Dreamweaver specific, they're a general web technology available on any server.
    A good primer here
    http://www.projectseven.com/products/menusystems/pmm2/ug-examples/includes/index.htm
    Do you already have a hosting account? Does it have PHP available?
    jtechmiami wrote:
    Imagine a 100 or 200 page site, perfectly functioning and on the air. Then, one day, you need to add or delete some button, or simply change a link. You need to change the menubar in ALL 200 pages, and then re-publish them all. Quite a work, ah ?
    Not with SSIs. Simple sitewide menu updates take a few seconds.
    You edit a single text file locally (either button labels or a CSS rule for styling the button), upload (1-2 seconds) and every page on the site is instantly updated.
    Much better than DW Templates.

  • Can I add datafile bigger then 2GB

    Hi all,
    Can I add datafile bigger then 2GB (on the raw device) to the tablespace ?
    I get err:
    ORA-01119 : error in creating database file '/opt/DISK/data02'
    ORA-27042 : not enought space on raw partition to fullfill request
    Aditional information : 1
    And
    partition has size 4096543 kB
    when I use partition with size 2GB it is Ok.
    Is it limitation by Linux ?
    I have linux 7.1
    and oracle 8.1.7
    What can I do ?
    thanks
    null

    If you want to use raw devices with linux you have to use the utility 'raw' to map the device. You could also use the Logical Volume Manager (or both)
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Martin Silar ([email protected]):
    I do not know where it is my problem.
    I wont to create datafile on raw disk and
    I wont to need raw disk with 4GB size, becose
    I can not create more logic devices on my SCSI disk then 15 logic partition. Disk have 39GB.
    I have problem with add raw datafile to tablespace.
    Have you sambody idea ?
    thanks Martin<HR></BLOCKQUOTE>
    null

  • Write an algorithm to sort an array of integers

    "Write an algorithm to sort an array of integers"
    I was asked this at an interview and required to do it in 5 mins. I don't think you can use sort them by putting them in a collection, i think you need to write an algorithm from scartch. Any idea what the best way to do this would have been?

    Depends what you mean by "best."
    BubbleSort is probably the only one I could write off the top of my head in five minutes, but as sorting routines go for practical use, it sucks. If you know how to write MergeSort or QuickSort or dman near anything off off the top of your head, that would proabably be better.
    No one sorting algorithm is "best" without any context, however.
    If you don't know any sorting algorithms, use google or your data structures and algorithms textbook.

  • How to convert an array of Integers into String

    So how can an array of integers be converted into a string?
    As I do not have a javac with me now, I hope you guys could help.
    Can it be done this way:
    int [] value = new int[] {2,3,4,5,6,7}
    String strValue = "";
    for (i=0; i<value.length-1; i++)
    strValue += value;

    Instead of working with Strings, I would suggest you use a StringBuffer. It will improve memory utilization.
    Like this:
    int [] values = new int[] {2,3,4,5,6,7};
    StringBuffer sbTmp = new StringBuffer();
    final int size = values.length;
    for (i = 0; i < size; i++) {
    String intStr = Integer.toString(values);
    sbTmp.append(intStr);
    String strValues = sbTmp.toString();

  • Functions to read and display an array of integers

    Hi guys,
    I am trying to implement with a class called Sort a function to read in an array of integers from a file and a function to display that array.
    public class Sort
         public static int[] read(String file) throws IOException
            /* Create Reader object to read contents of file */
            BufferedReader br = new BufferedReader(new FileReader(file));
            /* Read file and store lines in ArrayList */
            ArrayList<Integer> list = new ArrayList<Integer>();
            /* Variable */
            String in;
            /* While not equal to null reads data from file */
            while ((in = br.readLine()) != null)
                /* Adds data from file to ArrayList */
                list.add(Integer.parseInt(in));
            /* Converts ArrayList into an array */
            int[] array = new int[list.size()];
            for(int i = 0; i < list.size(); i++)
                /* Get array elements */
                array[i] = list.get(i);
            /* Returns array */
            return array;
        public int display()
            for (int i = 0; i < list.size(); i++)
                System.out.println(list.get(i));
    }I am having one of those moments when you forget everything, I need help with display the array in a seperate function, will someone help me please?
    Thanks!

    I know that its just implementing it.
    I have:
    public void display()
            for(int i = 0; i < array.length; i++)
                System.out.println(array);
    But I'm lost on how to make this work, i.e it says "cannot find array variable". I've not done Java for a while and feel like I have forgot everything!
    Edited by: mbruce10 on Nov 15, 2009 1:31 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Getting Largest Int From an Array of Integers

    public class TestMe
        public TestMe(int ai[])
            _numbers = ai;
    public int getBiggest1()
            int i = _numbers[0];
            for(int j = 1; j < _numbers.length; j++)
                if(_numbers[j] >= _numbers[j - 1] && i < _numbers[j])
                    i = _numbers[j];
            return i;
        public int getBiggest2()
            double d = Math.random();
            int i = _numbers[0];
            for(int j = 1; j < _numbers.length; j++)
                if(d >= 0.10000000000000001D && i < _numbers[j])
                    i = _numbers[j];
            return i;
      private TestMe()
        private int _numbers[];
    }can anyone see what is wrong with either of the two methods as regards returning the largest integer from an array of integers.
    As far as I can see they work no matter what ints are in the array.
    Any ideas anyone ?
    Regards
    Sean

    I used the following client program to use ur class:
    I also modified ur class a bit and made the other constructor (the one with no arguments) as public to extend the class.
    Both the functions, viz, getBiggest1() and getBiggest2() are working fine...
    Now, I am new to JAVA so I might have made mistakes. Please correct me if there is anything wrong.
    /*Here is ur class that i have modified*/
    public class GetBiggest {
         public GetBiggest(int ai[])     {
              _numbers = ai;   
         public int getBiggest1()     {
              int i = _numbers[0];
              for(int j = 1; j < _numbers.length; j++)           
              if(_numbers[j] >= _numbers[j - 1] && i < _numbers[j])
                   i = _numbers[j];
              return i;
         public int getBiggest2() {       
              double d = Math.random();
              int i = _numbers[0];       
              for(int j = 1; j < _numbers.length; j++)           
              if(d >= 0.10000000000000001D && i < _numbers[j])
                   i = _numbers[j];
              return i;
    public GetBiggest()     {
    private int _numbers[];
    /*Ur class ends here*/
    /*My client program starts here*/
    import java.lang.*;
    public class TestBiggest extends GetBiggest
         public static void main (String args[])
              int[] arrNums = {30, 20, 40, 10};
              GetBiggest GB = new GetBiggest(arrNums);
              int greatest = 0;
              try
                   greatest = GB.getBiggest2();
                   System.out.println("\nBiggest number is : " + greatest);
              }//end try block
              catch(Exception e)
                   System.out.println("Some error");
              }//end catch block
         }//end main
    }//end class
    /*End of my client program*/

Maybe you are looking for

  • Can't fetch Album Cover Art from Store, allthough Album exists!

    hi everybody! I have a title in my library that I want to get the cover for from the iTunes Store. It is definately available and I named it exactly after the one in the store (album, title, artist, genre...) But iTunes refuses to load the cover...it

  • Is it possible to edit the voice of a song created in Garage band?

    Hello to all! Using music tracks, I am singing songs in different languages using Garage band. After I import these songs into my FCPX projects, is it possible for me to break up the individual tracks [the music track apart and the voice track apart]

  • Getting a value of a data member that is in a subclass only

    Hi i have one superclass called membership and it has the data members name, password, readingPoints. i have two subclasses of the membership class called silver and gold. the gold subclass has an extra data member called statusPoints. i have no idea

  • [SOLVED]Gnome 3 doesnt ask me for sudo password

    So, I'm a noob. I've installed Arch, everything went relatively well and I have a working Gnome 3 environment. However, when I type "sudo blablabla" (like "sudo pacman -S some_package") Gnome never asks me for a password, it just silently does what I

  • Aperture and iPhoto workflow?

    The problem: I'm not happy with quality of previews used by aperture to display slideshows. Even at maximum resolution and quality setting they are too soft to my taste. The same photos exported as jpgs out of aperture are sharp. I guess there must b