|
Looks like it will take weeks to get through that doc [ ] Can you please explain in simple words what is the cause and resolution of this behavior if I may request so ?
|
|
|
|
|
cagespear wrote: Looks like it will take weeks to get through that doc
So just search for another one. They're plentiful. Here for example.
cagespear wrote: Can you please explain in simple words what is the cause...
Computers are binary (i.e., base-2) machines, thus they cannot exactly represent floating-point numbers as you might think.
cagespear wrote: ...and resolution of this behavior if I may request so ?
Epsilon.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
There are two problems with real numbers on computers.
1. Not every real number have an exact binary representation. For example 0.1 when represented in binary is 0.0001100110011001100110011001100110011001100110011001101 now when you convert it back to real number you will get 0.10000000000000001. Note you can try this calculation by hand and this inaccuracy has got nothing to do with how we represent real numbers in computer.
2. There are uncountably infinite real numbers but computers can only represent and manipulate finite numbers (Well at least in hardware). This means that not every real number can be expressed in computer.
Hope this makes it clear.
-Saurabh
|
|
|
|
|
Simply, this is related with binary representation of floating point numbers.
Member 3611002 wrote: The results of both d and d1 are 37.619999999999997 (unexpected)
what do i do to get d=37.62 and d1=37.62
This is normal and there is nothing to do for a double type. if you format that number back using format string %.2f, you will get 37.62 again.
I'll try to comment on, shortly.
As you may know, double is a 64 bit floating point number. There are some special formats (standards defined by IEEE in this case) to store it in memory. It consists of 3 parts; sign (1), exponent (11), significand (52 bits). There are also special rules for storing exponent and significand. Most important one, exponent part is two's exponent, not ten's. Moreover, some operations (i.e. rounding and normalization) have been applied to a floating point number after every operation. After all, it is stored as nearest possible value fitting into these rules.
|
|
|
|
|
This is what I am doin...
string filename; //filename contains "c:\\new folder\\file1.txt"
....
....
ofstream myfile;
myfile.open (filename, ios::app);
When I compile or built this I get
error C2664: 'void __thiscall std::basic_ofstream<char,struct std::char_traits<char=""> >::open(const char *,int)' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_tr<br="" mode="hold">aits<char>,class std::allocator<char> >' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
Please help me get rid of this or any suggestion to make changes to this. THANKS
|
|
|
|
|
pl_kode wrote: myfile.open (filename, ios::app);
Change to
myfile.open (filename.c_str(), ios::app);
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
|
|
|
|
|
|
It does not show any error like this..
Nor does its creating any file in the specified path.
Wt shud I do.
|
|
|
|
|
pl_kode wrote: filename contains "c:\\new folder\\file1.txt"
did you created the "new folder" directory in "C:\" drive, you should not expect open API will do that.
|
|
|
|
|
for istance, you may call myfile.rdstate() .
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
|
|
|
|
|
I tried it by using rdstate(). Still stuck with the same thing.
|
|
|
|
|
pl_kode wrote: I tried it by using rdstate()
What is the return value?
Have you read the Rajkumar reply?
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
|
|
|
|
|
pl_kode wrote: myfile.open (filename, ios::app);
does replacing it with something like : myfile.open (filename.c_str(), ios::app); works ?
|
|
|
|
|
It doesn't show any errors like this. But it also do not create a file in the folder.
|
|
|
|
|
Can you try creating a file manually there ? Do you have the write access to the path?
|
|
|
|
|
Yes if i give ..
ofstream myfile;
myfile.open ("c:\\New folder\\file1.txt", ios::app);
It works. Even a file is created.
But I want it the other way.
|
|
|
|
|
can you post how you initialise filename variable. or check the value of filename before open(),
cout << filename.c_str();
|
|
|
|
|
Hi all,,
I m using one plug-n-play device like.. printer
whose driver also installed on my machine..
now i want to get the information about this device
like : 1> on which port it is connected
: 2> what is its device Id
: 3> what is its company name & Driver info.
at Run time .... how can i get these using VC++
and in which version of VC++
or give any solution which work in VC++6.0
ur reply really matters me....
thanks in advance...
|
|
|
|
|
|
If anyone can give me direction as to modifying the Crystal Report default path to ...\MyDocuments\. I would appreciate it.
I am working on an application using C++/MFC, which creates reports (using crystal reports), but the default path is preferred to be in the My Documents folder. Otherwise, to the path set previously by the application's operator. I am using Crystal Reports (version 8.5).
Thanks.
modified on Monday, April 28, 2008 8:53 AM
|
|
|
|
|
Hi All, Look at the following code snippet. My aim is to disable the button for some time say 2 seconds and enable it thereafter. What i noticed if i repeatedly click the button before 2 seconds lapsed then the all clicks i did get queued even the button itself was disabled at the very first click. The result of above said is that the all queued events get called one by one. Which is not desirable and i am able to notice as many traces as the clicks i did before 2 secs in my output window.
my aim is simple. I just don't want the button's handler to be called after the same gets disabled.
void CMYDlg::OnMyButton()
{
m_mybtn.EnableWindow(false);//disable button on its own click handler
Sleep(3000);
TRACE("___demo___");
m_mybtn.EnableWindow(true);
}
Your help and suggestion will be highly appreciated...
thanks
Raman
|
|
|
|
|
hey if any of you have problem understanding my question then please reply to this thread.
|
|
|
|
|
Member 3068970 wrote: Sleep(3000);
You can't put a simple in there. You will block your main thread (which is the UI thread too) meaning that no message will be processed. So, all your clicks will still be queued. You have to use a timer to simulate such behavior. Disable the button and start the timer in OnMyButton and re-enable the button once the timer fired.
|
|
|
|
|