I was just encountering a bug where assignment of a DWORD var wasn't working right.
I was converting a float directly to a DWORD during the assignment. It worked most of the time, but every now and then it didn't.
I'm not completely sure what causes this problem, but I'm guessing it has to do with the byte alignment of the var in the memory.
So, just wanted to say... always convert your floats into longs before converting them to DWORDs, and convert your doubles to long-longs before converting them to QWORDs.
Do you have a short example which shows this?
Yeah, but it's spread through several different files (not short) in a large (well, large for me) project.
I found some links that seem to be very similar:
I don't think it can help to cast your float to a long and then cast it to DWORD, because in a couple of Windows headers, you'll simply find
Originally Posted by Yarin
The first link you give multiplies the floating point value by UINT_MAX; I am not very surprised that things come out wrong in that case. The second link is just one of the many reasons to eschew .NET - it has nothing to do with C++ per se.
typedef unsigned long DWORD
Can't you make a (small) test program which shows your problem in a few lines of code?
Computer Programming: An Introduction for the Scientifically Inclined