ASingerMustDie
Programmer
Hi All,
I have written a program for which I wrote an object to mimic dynamic 2D arrays, using a single imension array, and it has been working fine.
However, in a newer part of the program, when the method GetXY is called (to get the value at a certain coordinate), a value of -1.#IND000000000 is being returned, i.e:
currentValue = my2DArray.GetXY(xCo, yCo);
// currentValue is now -1.#IND000000000
Does anybody have any idea why this may be happening? I have traced through the GetXY function in the debugger and it works fine, it runs to the return line (return array[arrayValue]) and should be returning the correct value (array[arrayValue] is the expected value)...what is happening?
Any help would be greatly appreciated
double Array2D::GetXY(int xCo, int yCo)
{
// Calculate one-dimension equivalent of given values
int arrayValue = (yCo * xDim) + xCo;
// Ensure the value is within the array size and return
// corresponding value, or return NULL
if (arrayValue >= 0 && arrayValue < (xDim * yDim))
{
// The debugger traces to here with array[arrayValue]
// being the expected value
return array[arrayValue];
}
else
{
return NULL;
}
}
I have written a program for which I wrote an object to mimic dynamic 2D arrays, using a single imension array, and it has been working fine.
However, in a newer part of the program, when the method GetXY is called (to get the value at a certain coordinate), a value of -1.#IND000000000 is being returned, i.e:
currentValue = my2DArray.GetXY(xCo, yCo);
// currentValue is now -1.#IND000000000
Does anybody have any idea why this may be happening? I have traced through the GetXY function in the debugger and it works fine, it runs to the return line (return array[arrayValue]) and should be returning the correct value (array[arrayValue] is the expected value)...what is happening?
Any help would be greatly appreciated
double Array2D::GetXY(int xCo, int yCo)
{
// Calculate one-dimension equivalent of given values
int arrayValue = (yCo * xDim) + xCo;
// Ensure the value is within the array size and return
// corresponding value, or return NULL
if (arrayValue >= 0 && arrayValue < (xDim * yDim))
{
// The debugger traces to here with array[arrayValue]
// being the expected value
return array[arrayValue];
}
else
{
return NULL;
}
}