CUDA giving random answers

When working on CUDA, I’ve sent the program an equation and gotten the right answer–let’s call this Case A.
Then I changed a variable and got a different answer–Case B.
When I changed the problem back to how it was in Case A (and yes, I’m positive it’s the same), I keep getting wildly different answers from the first time through Case A. Is this normal for CUDA (a memory allocation issue, perhaps), or does it seem like something’s wrong?

Are you checking error codes?

I’m a complete novice (4 days’ experience)–how do I check error codes?

The return values of cuda* or by using cudaGetLastError(). If they don’t equal cudaSuccess, something has gone wrong (and it’s probably a segfault in your code).