jaehov Posted February 15, 2009 Report Share Posted February 15, 2009 Hey techies I am working with a pre-existing test tool with LV 7.1 I need to convert a Decimal String "1234567899" to an Integer equivalent (no truncation or other formatting) Essentially I want the string "1234567899" to be converted to the Integer (1234567899) I know in LV 8 this would be a breeze with U64. But how can I perform get same result in LV 7.1 ? thanks The new guy on the block Quote Link to comment
jdunham Posted February 16, 2009 Report Share Posted February 16, 2009 QUOTE (jaehov @ Feb 14 2009, 11:02 AM) Essentially I want the string "1234567899" to be converted to the Integer (1234567899)I know in LV 8 this would be a breeze with U64. But how can I perform get same result in LV 7.1 ? Umm, that number fits fine in an I32. Assuming you are really having a problem, why not use DBLs? Just because it's not limited to integers doesn't mean its a bad choice for them if U32 is too small. Quote Link to comment
jaehov Posted February 16, 2009 Author Report Share Posted February 16, 2009 QUOTE (jdunham @ Feb 15 2009, 01:22 AM) Umm, that number fits fine in an I32. Assuming you are really having a problem, why not use DBLs? Just because it's not limited to integers doesn't mean its a bad choice for them if U32 is too small. i actually got the number wrong, its longer than that. Try "12345678991234567899" Quote Link to comment
Mark Yedinak Posted February 16, 2009 Report Share Posted February 16, 2009 Without using a different data type such as a double then your only real option is to handle 64 bit integers yourself. You would have to do this by using two 32 bit integers and creating your own methods for operating on those values. this would be a non-trivial exercise but if you must have them in integer format this is one of your only real alternatives. Much more memory intensive but possibly easier to work with and more extensible would be to store each digit of the number as an element of a byte array. Again, you have to create your own methods for operating on the numbers but they would be fairly straight forward to implement. Think back to your early days of learning math. Quote Link to comment
jaehov Posted February 17, 2009 Author Report Share Posted February 17, 2009 QUOTE (Mark Yedinak @ Feb 15 2009, 04:15 PM) Without using a different data type such as a double then your only real option is to handle 64 bit integers yourself. You would have to do this by using two 32 bit integers and creating your own methods for operating on those values. this would be a non-trivial exercise but if you must have them in integer format this is one of your only real alternatives. Much more memory intensive but possibly easier to work with and more extensible would be to store each digit of the number as an element of a byte array. Again, you have to create your own methods for operating on the numbers but they would be fairly straight forward to implement. Think back to your early days of learning math. thanks for the response. Can you help me with my example VI ? I have connected my string control to a unsigned byte array. Im unsure of where to go from here?? http://lavag.org/old_files/post-7622-1234806972.vi'>Download File:post-7622-1234806972.vi Quote Link to comment
Mark Yedinak Posted February 17, 2009 Report Share Posted February 17, 2009 Here is a simple example for adding two large numbers. It should give you a good idea of how to proceed. If you will be doing more operations with larger numbers, or large number of numbers then you may need to spend some time optimizing the code for efficiency. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.