Discussion:
Fastest way to format an array of numbers
(too old to reply)
FightOnSCTrojan
2008-08-14 22:40:18 UTC
Permalink
I am collecting 2D array of DBLs to be later processed by other Vis.  
The process worked fine when I saved the array to a file (standard %.3f, write to spreadsheet) formatting, then later have a separate VI to open the file and process it.
The same process did not work when I tried to process the 2D array on the fly, without saving/opening to file.  
After debugging, I found out what was holding me back. Yep you guessed it, the formatting. Without save to spreadsheet, instead of “0.000”, the value is not 2.803E-42 (I need to to be 0.000). What is the most efficient way to format the numbers to “.3f”,  on the fly (without saving to file)?
Best, 
Santiago
FightOnSCTrojan
2008-08-14 22:40:18 UTC
Permalink
BTW...My current solution is to covert array to spreadsheet string...then convert the string back to an array....
Karissa
2008-08-15 03:40:07 UTC
Permalink
.3f is the same as a precision of 3 input to the number to fractional string vi (which can handle arrays automatically)   To keep only a precision of 3 you can also do it numerically by multiplying by 1000, rounding then dividing by 1000.   Here is a screenshot of the code using the two different methods. The numeric method should be fastest.  


format array of numbers.png:
http://forums.ni.com/ni/attachments/ni/170/349506/1/format array of numbers.png
Loading...