Sorry. I didn't mean to offend you. I guess I should have worded that more carefully. I was just trying to point out that his question was a little deeper than people were giving it credit for. As you said, the floating point representation of 1/3 is not exact. Yet, pow(1,1/3) correctly returns 1, even though there are two equally valid complex solutions. Why, then, shouldn't pow(-1,1/3) return -1? It is, after all, the only real-valued solution. I guess the ANSI C developers opted for efficiency rather than completeness. Again, sorry if I offended you. That wasn't my intention.
Barvus
Posts
-
pow(-1, 0.3333333333) doesn't return -1 -
How do I load a 16x16 icon?Hey, thanks for the tip! Good to know. I wonder why that's not documented in MSDN.... Or is it? Must be buried somewhere deep.
-
pow(-1, 0.3333333333) doesn't return -1>Is "the" cube root of -1, -1? >No. >It is one of at least two cube roots. By that logic, pow(1, 1/3) should return undefined too, since -1/2 + j * sqrt(3)/2 and -1/2 - j * sqrt(3)/2 are also solutions. (It doesn't. It returns 1, as you would expect.) For what it's worth, the calculator in Windows XP returns "Invalid input for function" when you try to do (-1)^(1/3). I think that's what most calculators that don't handle complex numbers do.
-
How do I load a 16x16 icon?Thanks, Mike! That did the trick. Much appreciated.
-
How do I load a 16x16 icon?Hmmm... I'm still getting the same error 1831. What am I doing wrong? :confused: m_hIconX = LoadImage(NULL, MAKEINTRESOURCE(IDI_X), IMAGE_ICON, 16, 16, 0); DWORD dwError; dwError = GetLastError();
-
How do I load a 16x16 icon?Just an update. I got it to work by doing the following: HANDLE hIcon; hIcon = ::LoadImage(NULL, "res\\icon1.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE); m_wndSBC.SetIcon(0, (HICON) hIcon); But I'd still like to know why it didn't work the other way, if anyone can help. Thanks.
-
How do I load a 16x16 icon?I'm trying to display a small icon in a CStatusBarCtrl. I created a 16x16 icon, IDI_X, in the resource editor, then I tried the following: HICON hIcon; hIcon = theApp.LoadIcon(MAKEINTRESOURCE(IDI_X)); m_wndSBC.SetIcon(0, hIcon); The icon is resized to 32x32 and doesn't fit in the status bar. The CApp::LoadIcon documentation says it can only be used to load an icon whose size conforms to the SM_CXICON and SM_CYICON system metric. It says to use LoadImage instead. So, I tried this: HANDLE hIcon; hIcon = LoadImage(NULL, MAKEINTRESOURCE(IDI_X), IMAGE_ICON, 0, 0, 0); DWORD dwError; dwError = GetLastError(); That didn't work either. LoadImage returns NULL and GetLastError returns 1813: "The specified resource type cannot be found in the image file." Can anyone help?
-
Problem with CPropertySheet as child of CDialogI have a CPropertySheet derived class that's a child of a CDialog derived class (main app window.) When a control on the property sheet has focus and I take an action that changes the active window, things get very strange. It looks like an endless loop of WM_GETDLGCODE messages are being generated and processed, so everything locks up. Anybody have any ideas what causes this or how to fix it? Thanks.