Does anyone know for a fact if the following will be a problem?
I have a multidimensional array P(35, 7) that stores some integer numbers in some subsets (3, 4, 7) and some floating point numbers in the other subsets (1, 2, 5, 6).
For specific reasons, I do not wish to use seperate arrays nor Types, so don't suggest to use them please. :)
Because an array can only be declared as integer P(35, 7) or float P#(35, 7), I can't actually have integers in subsets 3, 4, and 7.
So what I want to know is if I create a float array P#(35, 7) and if I perform only 'integer math' on subsets 3, 4, and 7, is there a possibility that the numbers in those subsets could become non-integers do to floating point inaccuracies?
I know you're asking yourself what I mean by 'integer math', so I will explain. For the subsets in question, I will only ever add or subtract exact integer numbers to/from them (i.e. 2.0 + 5.0, or 134.0 - 17.0).
I may even have to perform multiplication (i.e. 32.0 * 7.0).
I probably won't be able however to perform division since that could lead to decimal parts (unless I know in advance that it would not).
So, in other words, if a float variable is set to an integer value (i.e. 4.0), will the zero part of that float always remain zero? Or is there a possibility that it could become non-zero (i.e 4.0000000000001) due to floating point inaccuracies?
The reason I am concerned is because I want to perform checks on the 'integer' subsets 3, 4, and 7 to see if they equal certain values (i.e. If P#(12, 3) = 20 Then ...).
I am afraid that due to floating point inaccuracies, that the checks could fail (i.e. P#(12, 3) = 19.99999999999).
So, does anyone know if I will encounter problems if I perform addition or subtraction on the floats?
Will I encounter problems if I perform multiplication on the floats?
What about performing division?
I have a multidimensional array P(35, 7) that stores some integer numbers in some subsets (3, 4, 7) and some floating point numbers in the other subsets (1, 2, 5, 6).
For specific reasons, I do not wish to use seperate arrays nor Types, so don't suggest to use them please. :)
Because an array can only be declared as integer P(35, 7) or float P#(35, 7), I can't actually have integers in subsets 3, 4, and 7.
So what I want to know is if I create a float array P#(35, 7) and if I perform only 'integer math' on subsets 3, 4, and 7, is there a possibility that the numbers in those subsets could become non-integers do to floating point inaccuracies?
I know you're asking yourself what I mean by 'integer math', so I will explain. For the subsets in question, I will only ever add or subtract exact integer numbers to/from them (i.e. 2.0 + 5.0, or 134.0 - 17.0).
I may even have to perform multiplication (i.e. 32.0 * 7.0).
I probably won't be able however to perform division since that could lead to decimal parts (unless I know in advance that it would not).
So, in other words, if a float variable is set to an integer value (i.e. 4.0), will the zero part of that float always remain zero? Or is there a possibility that it could become non-zero (i.e 4.0000000000001) due to floating point inaccuracies?
The reason I am concerned is because I want to perform checks on the 'integer' subsets 3, 4, and 7 to see if they equal certain values (i.e. If P#(12, 3) = 20 Then ...).
I am afraid that due to floating point inaccuracies, that the checks could fail (i.e. P#(12, 3) = 19.99999999999).
So, does anyone know if I will encounter problems if I perform addition or subtraction on the floats?
Will I encounter problems if I perform multiplication on the floats?
What about performing division?