Okay, I have a problem that is really perplexing me. I have written an extensive VBA program that will take data sets recorded by two different instruments and prepare them for use in a piece of visualization software. One of the tricky steps involved pairing up precipitation data with the sewer level data.
The way the loggers work is like this - the sewer level logger logs the depth of flow in the sewer every 5 minutes, no matter what. The precipitation logger logs the date and time that 0.01 inches of rain falls. So, what you end up with, after a month, is 2 different .csv files that need to be merged, but they have different time scales.
My spreadsheet goes through and (among many other steps) combines the date and time into a single value for both the level logger data and the precipitation data. It then goes through each date and time that was recorded in the precipitation data (each representing 0.01 inches of rainfall) and looks through all of the date/time data in the level logger data, finds the closest one, and adds the precipitation incrament to that time step (I made the precipitation incrament a user-input variable so that it could easily be changed if, for example, another precipitation logger model was used that only recorded 0.1 inches of rain or somethign like that).
Here is where the problem comes in. I input the precipitation incrament as 0.01 inches. So, you would expect that all of the values recorded for precipitation would be some multiple of that (0.01, 0.02, 0.03, 0.10, 0.25, etc.) depending on how much precipitation fell during that level logger time step. What actually gets recorded in the spreadsheet is 0.00999999977648258 (instead of 0.01), or 0.0299999993294477 (instead of 0.03), etc.
I tried to fix it by ignoring the underlying problem and using the Round function as follows: PrecipNew = Round (PrecipExist + PrecipIncrament, 2). That should look at the existing precipitation recorded at that time step in the workbook and add the incrament. PrecipNew is then written back out to the workbook. The Round function should truncate all of the extraneous digits and spit out what I was expecting (0.01, 0.02, 0.03, etc.). It does not.
The variables are all dimensioned as Single (PrecipNew, PrecipExist, and PrecipIncrament). Has anyone else ever run into this or know why this is happening? I've spent all weekend searching and banging my head against the wall trying to fix it. Thanks!
The way the loggers work is like this - the sewer level logger logs the depth of flow in the sewer every 5 minutes, no matter what. The precipitation logger logs the date and time that 0.01 inches of rain falls. So, what you end up with, after a month, is 2 different .csv files that need to be merged, but they have different time scales.
My spreadsheet goes through and (among many other steps) combines the date and time into a single value for both the level logger data and the precipitation data. It then goes through each date and time that was recorded in the precipitation data (each representing 0.01 inches of rainfall) and looks through all of the date/time data in the level logger data, finds the closest one, and adds the precipitation incrament to that time step (I made the precipitation incrament a user-input variable so that it could easily be changed if, for example, another precipitation logger model was used that only recorded 0.1 inches of rain or somethign like that).
Here is where the problem comes in. I input the precipitation incrament as 0.01 inches. So, you would expect that all of the values recorded for precipitation would be some multiple of that (0.01, 0.02, 0.03, 0.10, 0.25, etc.) depending on how much precipitation fell during that level logger time step. What actually gets recorded in the spreadsheet is 0.00999999977648258 (instead of 0.01), or 0.0299999993294477 (instead of 0.03), etc.
I tried to fix it by ignoring the underlying problem and using the Round function as follows: PrecipNew = Round (PrecipExist + PrecipIncrament, 2). That should look at the existing precipitation recorded at that time step in the workbook and add the incrament. PrecipNew is then written back out to the workbook. The Round function should truncate all of the extraneous digits and spit out what I was expecting (0.01, 0.02, 0.03, etc.). It does not.
The variables are all dimensioned as Single (PrecipNew, PrecipExist, and PrecipIncrament). Has anyone else ever run into this or know why this is happening? I've spent all weekend searching and banging my head against the wall trying to fix it. Thanks!