|
Cedric Moonen wrote: for instance if the value is between -0.000001 and 0.000001, then you can say it is equal to 0. That's the only way to work with floating point values, because they will never be 100% precise and you have to keep that in mind
Yeap the sign associated with it was the real issue. it may remain negative (even I expect 0.0f)
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Sarath. wrote: the sign associated with it was the real issue
Shouldn't be - the IEEE standard requires that positive or negative zeros compare equal.
|
|
|
|
|
With double data type you'll get a better approximation (you know you can't get exact values)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
It's because standard floats and doubles cannot exactly represent 0.6.
The representation of 0.6 as a float can be determined by working out what sum of binary fractions (1/2n) best approximates it - you can see it's going to be something like 0.5 + 0.0625 + 0.03125 + .... - SpeedCrunch[^] (a nice calculator) gives it as this:
0b0.1001100110011001100110011001100110011001100110011001100110011001101
Infinitely recurring binary time...
Read this document[^] for the full story.
|
|
|
|
|
See here and here. In short, not all floating-point numbers can be stored in binary without some rounding.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hello,
I am compling one of the sample projects which I got after installing WMSDK.
I am using VS2009 and I compiled the project from "C:\WMSDK\WMFSDK11\samples\Metadataedit" but getting error which tells that it's not getting declarations of some symbols/variables used in 'string.h'. I am confused thinking what setting am I missing ? can anybody please guide why I am getting those error ?
Thanks in Advance.
regards,
Supriya
|
|
|
|
|
Are you talking about std::string ? If yes, then you have to #include <string></string> and not #include <string.h></string.h> .
EDIT: BTW, it is in general usefull to provide the exact error message, and not your interpretation of the message.
|
|
|
|
|
sorry here are some of the errors..
1>c:\program files\microsoft visual studio 9.0\vc\include\string.h(48) : error C2065: '_MaxCount' : undeclared identifier
1>c:\program files\microsoft visual studio 9.0\vc\include\string.h(48) : error C3861: '_Out_opt_bytecap_': identifier not found
1>c:\program files\microsoft visual studio 9.0\vc\include\string.h(48) : error C2144: syntax error : 'void' should be preceded by ')'
1>c:\program files\microsoft visual studio 9.0\vc\include\string.h(48) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\program files\microsoft visual studio 9.0\vc\include\string.h(48) : error C2059: syntax error : ')'
Regards,
Supriya
|
|
|
|
|
Check if your problem is similar to one described here[^].
|
|
|
|
|
Supriya Tonape wrote: can anybody please guide why I am getting those error ?
Have you tried including string (instead of string.h ) instead?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Yes I had tried that.
(sorry for late reply, I cudnt check mails.)
Regards,
Supriya.
|
|
|
|
|
Hi,
My C++ program (VS2005) has two parts. one part writes into a file and the other part reads from it.
The folder name is japanese. eg: C:\Documents and Settings\管理者
To read the file in this location,I am supposed to use an API (third party library) which takes the file location as a char*. I have the file location(C:\Documents and Settings\管理者) in a CString.
How do I convert this into a char* ?
I tried using the T2A macros, but the japanese string is not getting extracted. the char* pointer shows some junk charaters.
Any inputs on this ?
Thanks in advance.
|
|
|
|
|
It's better to seek the help of 3rd party library to provide Unicode interfaces. Other workarounds like renaming to ASCII and restoring it back after use will be painful.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
I m not sure but check if this helps you,
CString buf = _T("salut"); //the first string
char * Result; //the result
long len = wcslen (buf); //the length of "salut"
wcstombs (Result,buf,len); //conversion to char *
Result[len] = '\0';
|
|
|
|
|
Hi,
I would like to add some text in the cation of document. e.g. If I have a Test.doc then the caption for this document is Test.doc but I want to add some more text to it like "Mydoc" so the caption will become "Test.doc Mydoc". I know we need to change some registery entries but I want to change it for all office documents. Actually I m changing the extension of these documents as Test.gdoc so for all office docs with extension it should attach this caption.
Pls let me know that how could we achieve this.
Thanks
SNI
SNI
|
|
|
|
|
Using MFC? Override CFrameWnd::OnUpdateFrameTitle .
Here's the implementation I used to add a 'document is modified' marker:
void CMainFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
{
if ((GetStyle() & FWS_ADDTOTITLE) == 0)
return;
CDocument* pDocument = GetActiveDocument();
if (bAddToTitle && pDocument != NULL)
UpdateFrameTitleForDocument(pDocument->GetTitle() + (pDocument->IsModified()?"*":""));
else
UpdateFrameTitleForDocument(NULL);
}
|
|
|
|
|
THanks for your reply but i need this for Winword document. Once we open any document (Test.doc), it will show its name at top left but I want to append my string to the cation of it "Test.doc (MyDoc)".
Do you have any idea how to do it?
SNI
SNI
|
|
|
|
|
Hmmm - so how is that appropriate for a C++/MFC forum?
Anyway - the Word object model has 'Caption' properties for the Application and Window objects, but not for Document objects. I'd suggest you open the VBA IDE for Word and look through the Word object model with the object browser, to see if anything looks like it could be the property you need.
|
|
|
|
|
You need to get handle of Word you can use of FindWindow and then you can use of SetWindowText.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hi,
I had found many samples in socket programming. But all it deal with
simple text transfer between sockets. But I have to send CStringArray from server
to client. Anybody can help me?
Thanks in Advance
|
|
|
|
|
In the socket layer everything is considered as a stream of bytes.
Whatever you want to send or receive through sockets has to be converted to a stream of bytes.
Socket do not understand objects, don't differentiate between ASCII, UNICODE, BINARY etc.
«_Superman_»
|
|
|
|
|
|
It looks like you need more help on dealing with CStringArray s than with sockets.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello,
I am new to this forum so please point me in the right direction if I am posting incorrectly.
I have an application that uses Video For Windows for capturing Webcam images. I have only found two ways to get to the image. One is to save a DIB to a file and the other is to save a DIB to the clipboard. Saving to the clipboard seems to work ok. I was able to test by pasting it in MS Paint.
Below are the essential lines of source. I have removed the error checking for clarity. I have verified that hDIB is nonzero. I have been reading for way too many hours and not getting it.
Tom Hubin
thubin@earthlink.net
capGrabFrame ( hwndVideo ) ; // snapshot one frame
capEditCopy ( hwndVideo ) ; // save DIB to clipboard
OpenClipboard(NULL) ; // open the clipboard
HANDLE hDIB = GetClipboardData(CF_DIB) ; // get handle to DIB
// todo: fetch DIB from clipboard
CloseClipboard() ; // finished with clipboard
// todo: convert DIB to 8 bit grayscale
|
|
|
|
|
I can think of a couple of posting errors (neither shooting offences!) - it's unusual to post your email, as replies to your posting get sent to you.
And secondly, what is your actual question?
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|