07-17-2008 04:13 PM
I have a strange anomaly occurring. I am reading many (%.6f) doubles from a spreadsheet in which several need to be averaged and then create a new datasheet with the new data. The newly averaged values get written to a new spreadsheet with 6 digits of precision.
Here is my problem. When I average the values read in from the spreadsheet file, I may get a 7th bit of precision. I am dividing by an even number so the new 7th digit is a 5. Sometimes the digit rounds up and sometimes it doesn’t round. Ex. -4.6008545 will round to -4.600855 but -4.5835165 will remain at -4.583516. Is there a way to get a consistent rounding? And yes, we need to be that accurate.
I have LabView 8.5 and I write the spreadsheets with the Write to Spreadsheet File.vi and read them with the Read Spreadsheet File.vi. Thanks Jeff
07-17-2008 04:34 PM
07-17-2008 04:39 PM
07-18-2008 01:28 AM
Here's some code for rounding to the nearest multiple (0.00001 in your case) which uses common rounding. Read that thread before using it.
Please note that this should work if you divide a number input by the user, but might not work if you divide a number where you remove precision for the display (e.g. your number might look like 0.85 when in effect it is 0.849999999243, which means it will always round down).
Ah, looks like you can't download without logging in, so here's the code. Be sure to also read this thread.
07-20-2008 06:00 AM