|
Many compilers recognise memcpy as an intrinsic function and it will be substituted by an efficient machine code implementation by the compiler, especially in a release build. I'd leave it alone.
Steve
|
|
|
|
|
i have this rn = (double) (n/rCount)*(a/n)*(b/n)*(c/n)*(d/n)*(e/n); in my code
with debug i see that n = 3 rCount =6
a = 2 b = 1 c = 2 d = 2 e = 2
but rn = 0.000
what i do wrong?
int a=0,b=0,c=0,d=0,e=0,n=0,y = 0;
for (int i = 0 ; i < (rCount) ; i++)
{
if ( m_Array[i][5]== "N" || m_Array[i][5] =="n")
{
n = n +1;
if ( m_Array[i][0] == m_A)
{
a = a+1;
}
if ( m_Array[i][1] == m_B)
{
b = b+1;
}
if (m_Array[i][2] == m_C)
{
c = c +1;
}
if (m_Array[i][3] == m_D)
{
d = d +1;
}
if (m_Array[i][4] ==m_E)
{
e = e +1;
}
}
}
if (a ==0 || b ==0 || c==0 || d==0 || e ==0)
{
rCount = rCount*100;
}
if ( rn > ry)
{
m_R = "NO";
}
else if (ry > rn)
{
m_R = "YES";
}
CString strf;
strf.Format(_T("%lf"),rn);
AfxMessageBox(strf);
FileText.close;
|
|
|
|
|
When you divide integers only, the result will be an integer also (and then it will be casted to a double, but it is already rounded to an integer value). If at least one of the operand is a double, then the result will be a double.
So, you can simply multiply one of your integer by 1.0 in your formula (this will convert it to a double).
|
|
|
|
|
|
i did this
rn = (double) (n/rCount)*(a/n)*(b/n)*(c/n)*(d/n)*(e/n*1.0000);
but it still return me 0.000 :/
|
|
|
|
|
you have to do it for every division involving 2 integers... and no need to use 4 zeros; 1. will suffice
|
|
|
|
|
Actually you have to do the trick for each of the factors [^]
(I also made a little test ).
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.
|
|
|
|
|
Immunity18 wrote: rn = (double) (n/rCount)*(a/n)*(b/n)*(c/n)*(d/n)*(e/n);
cast should happen (in each factor) before division is performed
(otherwise integer division will result zero)
try :
<br />
double rn = ((double)n/rCount)*((double)a/n)*((double)b/n)*((double)c/n)*((double)d/n)*((double)e/n); <br />
<br />
Note that there is a smarter formulation of your expression:
<br />
double rn =(double)( a * b * c * d * e )/(rCount * n * n * n * n);<br />
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.
|
|
|
|
|
thanks and hm yes the second one is smarter
|
|
|
|
|
Hi there,
i have a problem with excel automation. I am using excel 2007 and Visual Studio 2005 with a dialog based MFC app. My code runs fine under excel 2000 but now i can't export any value to excel. Here now a code snippet of what i am doing:
pXL.CreateInstance(L"Excel.Application.12");
pXL->Visible[0] = VARIANT_TRUE;
WorkbooksPtr pBooks = pXL->Workbooks;
pBook = pBooks->Add((long)xlWorksheet);
pSheet = pXL->ActiveSheet;
pSheet->Name = "testname";
pSheet->Range["A1"]->Value = "1234";
this works fine to the pSheet->Range line. Excel opens, a new sheet is opened and this sheet is renamed to testname. But if i would write 1234 in the A1 excel cell a unhandled exception occurs and when i debug this the IDE jumps to the excel.tli file and displays this line:
#pragma implementation_key(1001)
inline void Excel::Range::PutValue ( const _variant_t & RangeValueDataType, const _variant_t & _arg2 ) {
_com_dispatch_method(this, 0x6, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL,
L"\x000c\x080c", &RangeValueDataType, &_arg2);
}
Now i don't now what to do, in the RangeValueDataType is the value i would write to the A1 cell and in _arg2 is a VT_ERROR value. I have searched the web and google groups, all people there using this pSheet->Range function and they don't have any problems with it. Anybody out there an idea whats going wrong there?
TIA and best regards,
Frank
|
|
|
|
|
LeMauvais1089 wrote: pXL.CreateInstance(L"Excel.Application.12");
Do you have both Excel 2000 and Excel 2007 on the same machine?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No, i have got a new laptop, there is only excel 2007 installed on it.
Thanks for the response and best regards,
Frank
|
|
|
|
|
So what happens if you use pXL.CreateInstance(L"Excel.Application") instead?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
exactly the same, excel starts and crash at Range->Value. Perhaps there is something wrong in my initialisation? Here is again a code snippet from my header file:
#import "progid:Excel.Sheet.12" auto_search auto_rename rename_search_namespace("Office12")
using namespace Excel;
i must admit that my knowledge of com is minimal. Perhaps you can see something on the code above
Thanks for your help,
Frank
|
|
|
|
|
LeMauvais1089 wrote: Perhaps you can see something on the code above
No, but I've got plenty of Excel 2003 examples.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all,
I have made one application in VC++. I want to make installer of that application so that I can deploy it on all client machines from server machine. Can I know any tool to make Installer or any method to make setup like this?
Thank in advance,
Priyank
|
|
|
|
|
Hi,
NSIS is a opensource freeware installer generator for windows. I used it for simple installation. I hope it has features that support your requirement. It has scripting to customise installer. please check this
http://nsis.sourceforge.net/Main_Page[^]
|
|
|
|
|
I have began to using directshow now,because VFW is not compatible on different devices. But another problem come up,that,I want to using H263 protole to compress and decompress the vedio data.But how should I do this?
The older codes running on VFW seems not suit for directshow.
Someone would give me a advice.
Thanks.
GOOD LUCK
|
|
|
|
|
Unfortunately, DirectBlow - er - DirectShow is not widely discussed here, mostly because it's a royal pain in the ass to deal with and nobody really likes doing it. Working with it is such a pain in the ass that I've turned down 6-figure salaries to avoid doing it.
I recommend that you use Google to find DirectShow help. Help is out there, but you REALLY have to look hard for it.
And I'm sure all the rules will have changed when dealing with Vista.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
DirectShow isn't quite as bad as Mr. Simmons states (maybe he should have held out for the 7-
figure jobs ) but its COM interfaces and semi-confusing documentation can make the learning curve
tough.
I've found it superior to its predecessor VFW, mostly because of WDM driver support. It's also
very flexible once you get the hang of it. That, unfortunately, can take some time (I mean
blood, sweat, and many tears)
That said, h.263 is no longer supported on DirectShow. As always with DirectShow, you WILL have
a hard time if you need to use a certain codec and you don't have one. The codecs included with
Windows are extremely limited. If you have a 3rd-party codec that is wrapped in a DirectShow
filter then you're in good shape.
My advice is get the Platform SDK (where the DirectShow SDK now lives) and study the features.
Make sure it's going to do what you need before you commit the time. The samples included in
the SDK work. Use them. It's sometimes nice to have working code you can study when the
documentation is vague.
Good luck!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Nah - it really does suck as back I say it does. I remember talking to Microsoft about something and walking away from the conversation completely aghast at the response I got. I don't remember exactly what it was we were talking about (I think my subconscious is blocking it), but I think it involved identifying devices you were trying to build filters for.
It was such a big pain in the ass that I promised myself that I'd never again go through the anguish and pressure of having to deliver something written for the piece of shit that DirectShow really is.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
Thanks.All.
I have dealt with such problem by using hard cording.
It works well now.
|
|
|
|
|
hi all,
i need information about using c# dll in vc++ .net
regards
venu
|
|
|
|
|
Do you want to use on the C++ or C++.net?
|
|
|
|