Here is a very good article on comparing floats. This method is much better than converting to text for the comparison. http://www.cygnus-software.com/papers/comparingfloats/Comparing%20floating%20point%20numbers.htm[^]
Jeff Archer
Posts
-
Compare/Convert Float to Text -
Using COM Object Invalid Pointer ErrorIf the return from this is 0x80040152 it is not being found in the registry. I suggest try the class id just as the next step of investigation. This HRESULT is either the client not registered correctly or using the incorrect ProdID.
-
Question about double #INF and #NANSorry, I guess I didn't present that very well. NAN is an exponent of 0x7FF with a non-zero mantissa. INF is an exponent of 0x7FF with a zero mantissa. Here are the actual fuctions I am using... bool IsInf (double d) { const INT64 iInf = 0x7FF0000000000000; if ((*(INT64*)&d & 0x7FFFFFFFFFFFFFFF) == iInf) return true; return false; } bool IsNan (double d) { INT64 exp = *(INT64*)&d & 0x7FF0000000000000; INT64 mantissa = *(INT64*)&d & 0x000FFFFFFFFFFFFF; if (exp == 0x7FF0000000000000 && mantissa != 0) return true; return false; }
modified on Friday, November 27, 2009 3:04 PM
-
Question about double #INF and #NANThanks. I was hoping to find such a table for double. Really, just a supporting documentation. I believe the values in my original question were correct.
-
Question about double #INF and #NANThe values in my original question are correct. (I believe) Just looking for supporting documentation. Thanks again for the time and thought you have put into this.
-
Question about double #INF and #NANYes, and thanks. But I'm still kind of looking for a nice table like they have for the 32 floats. Don't want to make the table myself because I'm not the expert. Just want to be able to refer to the expert.
-
Using COM Object Invalid Pointer ErrorThe HRESULT you have indicated is 0x80040152 - Could not find the key in the registry Sounds like the COM object you are trying to use is not correctly installed or you are not using the correct ProgID. Try using a CLASSID for your CreateInstance.
-
Question about double #INF and #NANDoes anyone understand the bit-wise representations of #INF and #NAN for the type double? Or could you point me to some real information on the internet? Also, what is the difference between Quiet NAN and Signaling NAN? I have been trying to find it with google all morning and I have found a lot of claiming to know but no actual knowledge. I know that for type float the bits are: 0x7FFFFFFF; // #NAN 0x7F800000; // #INF I believe that for type double the bits would: 0x7FFFFFFFFFFFFFFF; // #NAN 0x7FF0000000000000; // #INF However, this is just changing the exponent from 8 to 10 bits and assuming that if would be the same. I would feel much better if I could find some supporting documentation.
-
TImingIt's really not that complicated once you have done it a couple of times. The do while loop that you are using is extremely wasteful in terms of CPU utilization. The proper way to block a thread is with WaitForMultipleObjects. Also, you should never block the main thread of your application. The best solution would really be to use a background thread to draw on a BITMAP and use use BitBlt to transfer the image to the screen every 333 ms. As a side note the values returned by GetTickCount are really only accurate to 15.2 ms so using it to time 33 ms isn't going to work well on a loaded machine. The advantage of the multimedia timer is that you can truely have 1 ms accuracy. And by using a background thread and proper thread synchronization your code will scale properly on faster and multi core machines and still work correcly on a slower or heavly loaded machine.
-
TImingUse the MultiMedia timer with a callback function. It is the most accurate timing you can have in Windows. Lookup the following in the VC++ help: TIMECAPS timeGetDevCaps timeBeginPeriod timeSetEvent
-
MFC Menu Expansion [modified]Personalized Menu Behavior
-
MFC Menu Expansion [modified]Thanks. Really though I know this is a stupid question or maybe its just me but I haven't been able to find it in the help because I can't think what the feature is called to be able to search for it in the MFC docs or code. When I google "Menu Expansion" I get 7500 hits that all seem to have to do with web development, java, of C#.
-
How to extract variables from between html tags?In this message board the correct assumption is native C/C++. There are seperate message boards for .net, C#, and managed C++. So the best answer is MSXML and there are plenty of examples available by googling MSXML Examples.
-
How to extract variables from between html tags?Have you checked out MSXML? It will parse the xml and let you deal with through an object model.
-
MFC Menu Expansion [modified]What controls the hovering expansion of MFC menus? Or what controls which choices are shown before hovering on the little arrow to expand the rest of the menu? A. The feature is called Personalized Menu Behavior. The wizard code for it is in CMainFrame::OnCreate()
modified on Friday, October 9, 2009 6:48 PM
-
WaitForSingleObject(m_SomeThread->m_hThread, INFINITE);When the user clicks in the dialog too soon and you do WaitForSingleObject you are blocking the GUI thread of the dialog. i.e. it hangs. Never block your GUI thread. Instead use a message box to inform user that he has clicked too soon and then simply return from the OnClick handler. Also, use an hour glass cursor while the background thread is running to inform user that clicking isn't going to work. You could disable some or all of the controls on the dialog just before kicking off the background thread to prevent the user from doing anything while the thread runs. Then enable them once the thread is complete and it is safe to click again. Also consider that you can't allow the dialog to close while the background thread is running.
-
How to put MFC View full screen on second monitor?Could someone give me a hint on how I could show one view full screen on a second monitor while the app with all the navigation pane, toolbars, menus, etc. stays on the main monitor? Ideally, this would just be a second view opened for the current document that can escape the apps frame and go over to the other monitor and make itself full screen. I've considered just using a second app with sockets for communications between the two apps. I've considered using a secondary GUI thread with a CWnd derived object that is sort of operating outside of MFC's doc/view architecture.