|
While true, the documentation states "measured clockwise". Provided the user has turned the monitor the same direction using both vendor's drivers, one of them is clearly wrong.
Does WHQL still exist? If so, perhaps Microsoft would like a ping "Hey, you don't check this!".
|
|
|
|
|

modified 2-Jan-15 9:16am.
|
|
|
|
|
Are you and Scholar247 the same person? If so please request removal of one profile.
As to your questions:
- This site does not provide code to order. Google is the place for samples.
- The consequences of a race condition may vary from incorrect results, to a program not responding.
- There are many different situations when this may be appropriate, but it depends on the problem to be solved.
- Impossible to answer as any problem's ease of resolution depends on a lot of factors.
|
|
|
|
|
int g_x = 0;
DWORD WINAPI Add(void* p) //p unused parameter
{
g_x++;
}
void main()
{
HANDLE m_hArr[10];
int i = 0;
for( ; i < 10; i++ )
{
CreateThread( NULL,0,Add,NULL,0,&m_hArr[i]);
}
//Wait for all the 10 threads to complete its execution
::WaitForMultipleObjects(10,m_hArr,TRUE,INDEFENITE);
//Now print the result.You expect 10 but it may not be...
cout<<"g_x = "<
|
|
|
|
|
Because the order of the execution.
Suppose you have 4 floats a,b,c,d
and you want to sum up them.
In case of serial implementation, it will be like a + b + c + d
But in case of parallel, it may execute like
(a+b) + (c+d)
So the result wont be same.
This answers your 4th question.
|
|
|
|
|
2. Consequence of race condition:
Your resource will go to a corrupted state.
Not getting the expected result etc.,
|
|
|
|
|
:
modified 2-Jan-15 9:24am.
|
|
|
|
|
Your question is not clear. What is the connection between mult-threading and rounding errors?
|
|
|
|
|
Richard MacCutchan wrote: What is the connection between mult-threading and rounding errors?
His homework question?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks, I'm not an expert in rounding, but I will stand a round (or around).
|
|
|
|
|
Overheard many years ago that "C is strongly typed language".
So what's up with unspecified / unknown "standard definition " of int abs (int) overloaded by , again unknown source "standard", to <b>float abs ( float)</b>?
Is it just "progress" AKA from plain C to C "whatever is latest derivative of it" or just plain lack of real standards ?
Happy coding in 2015
Cheers Vaclav
|
|
|
|
|
|
Sorry I did not specifically say "C++".
I should have said "is C++ ( and derivatives ) strongly typed " to make the question clearer.
Maybe the question is just irrelevant with overloading, thus academic as I said in title.
Cheers Vaclav
|
|
|
|
|
Exactly, you said "Overheard many years ago that "C is strongly typed language".", and went on to talk about overloading. I responded that it (overloading) was not C it was C++. So I apologise that my answer was not very clear.
|
|
|
|
|
I should have said "is C++ ( and derivatives ) strongly typed "
No need. You just mixed concepts when including overloading - that's like comparing apples with the act of driving a car.
So restricting the question to C, it is indeed a strongly typed language, but in some instances not entirely strict about it. C++ is stricter.
For further reading, see f.ex. this wikipedia page.
|
|
|
|
|
How does one arbitrarily enable or disable a button on the Ribbon bar?
The OnUpdateCommand handler only allows you to specify a change in response to a button-click. But I want to enable or disable the button from elsewhere in the program.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Thanks for your response.
That macro allows me to add an OnUpdateCommandUI handler which gets called right after the button is clicked.
But how does it allow me to do something like ribbonButton.Enabled(FALSE); NOT in response to a button click?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I guess it's just a matter of creating a function that can enable or disable the button, something like:
void EnableButton(CMFCRibbonButton& ribbonButton, bool bEnable)
{
ribbonButton.Enable(bEnable);
}
or better still, a function that enables/disables all the buttons based on a set of rules ...
void EnableButtons(int nRule, bool bEnable)
{
switch (rule)
{
case 1:
ribbonButton1.Enable(bEnable);
ribbonButton2.Enable(bEnable);
break;
case 2:
ribbonButton1.Enable(bEnable);
ribbonButton6.Enable(bEnable);
ribbonButton7.Enable(bEnable);
break;
}
}
You then call this function from elsewhere in response to some arbitrary decision of your own.
|
|
|
|
|
Now you've hit upon the exact problem: The CMFCRibbonButton does not have an "Enable" method, or any method like it, hence my dilemma.
Thanks again for your time.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
I hear what you're saying, but that IsDisabled() property is read-only. And the SO question you link to says basically what we already know about the MFC macros.
That's why I can't figure this out.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Sorry nor can I. But given what I said about Word and the SO question, it must be possible. Unfortunately it is too many years since I used MFC in anger so I can't even try a few things. I wonder where all the CodeProject MFC experts are?
|
|
|
|
|
/*
TEST WITH THE FOLLOWING
PROBLEM 1
inputs:
infinity:999
no. of cities: 4
no. of paths:6
PROBLEM 2
inputs:
infinity:999
no. of cities: 5
no. of paths:10
*/
#include <stdio.h>
#define ALL -1
#define MAXCITIES 10
enum BOOL{FALSE,TRUE};
long*visited;//visited nodes set here
long*min_circuit;//min inner circuit for given node as start node at position indexed 0
long*ham_circuit;//optimal circuit with length stored at position indexed 0
long min_circuit_length;//min circuit lenth for given start node
int n;//city count
long matrix[MAXCITIES][MAXCITIES];//nondirectional nXn symmetric matrix
//to store path distances as sourceXdestination
long INFI;// INFINITY value to be defined by user
// function resets minimum circuit for a given start node
//with setting its id at index 0 and setting furthr node ids to -1
void reset_min_circuit(int s_v_id)
{
min_circuit[0]=s_v_id;
for(int i=1;i<n;i++) min_circuit[i]="-1;
}
//" marks="" given="" node="" id="" with="" flag
="" if="" it="" all="" nodes="" flag
void="" set_visited(int="" v_id,bool="" flag)
{
="" if(v_id="=ALL)" for(int="" i="0;i<n;i++)" visited[i]="flag;
" else="" visited[v_id]="flag;
}
//" function="" sets="" hamiltonion="" circuit="" for="" a="" path="" length
="" setting="" at="" index="" 0="" and="" furthr="" from="" current="" min_circuit
void="" set_ham_ckt(long="" pl)
{
="" ham_circuit[0]="pl;
" ham_circuit[i+1]="min_circuit[i];
" ham_circuit[n+1]="min_circuit[0];
}
//function" valid="" by="" finiding="" min="" inner="" given
="" combination="" start="" vertex="" next="" to="" such="" that
="" the="" 2nd="" of="" circuits="" is="" always="" s_n_v="" dest="" is
="" s_v="" possible="" values="" s_n_v,="" then="" returns="" the
="" length="" this="" combination
long="" get_valid_circuit(int="" s_v,int="" s_n_v)
{
="" int="" next_v,min,v_count="1;
" long="" path_length="0;
" min_circuit[0]="s_v;
" min_circuit[1]="s_n_v;
" set_visited(s_n_v,true);
="" path_length+="matrix[s_v][s_n_v];
" v="s_n_v;v_count<n-1;v_count++)
" {="" if(="" matrix[v][i]<infi="" &&="" !visited[i]
="" matrix[v][i]<="min
" )
="" set_visited(next_v,true);
="" }
="" return(path_length);
}
int="" main()
{
=""
="" printf("make="" sure="" that="" infinity="" value="" <="" sum="" distances\nset="" (signed="" long):");
="" scanf("%ld",&infi);
="" pathcount,i,j,source,dest;
="" dist="0;
" new_circuit_length="INFI;
" printf("enter="" no.="" cities(max:%d):",maxcities);
="" scanf("%d",&n);
="" count:");
="" scanf("%d",&pathcount);
="" paths:<="" source_id="" destination_id="" distance="">\n ids varying from 0 to %d\n",n-1);
//init all matrix distances to infinity
for(i=0;i<n;i++)
for(j="0;j<n;j++)
" matrix[i][j]="INFI;
//populate" the="" matrix
=""
="" for(i="0;i<pathcount;i++)
" return="" 0;
="" {
="" printf("[path="" %d]:",i);
="" scanf("%d="" %d="" %ld",&source,&dest,&dist);
="" if(source!="dest)
" matrix[source][dest]="matrix[dest][source]=dist;
" }
="" visited="new" long[n];
="" min_circuit="new" ham_circuit="new" long[n+2];
="" min_circuit_length="INFI;
" algorithm
="" for="" each="" vertex,="" s_v="" as="" a="" staring="" node
="" for(int="" s_v_id="0;S_V_id<n;S_V_id++)
" {="" and="" non="" start="" vertex="" i
="" set="" all="" to="" unvisited
="" set_visited(all,false);
="" visited
="" set_visited(s_v_id,true);
="" reset="" init="" minimum="" circuit
="" reset_min_circuit(s_v_id);
="" obtain="" circuit="" combination="" of="" new_circuit_length="get_valid_circuit(S_V_id,i);
" if="" newer="" length="" is="" less="" than="" previously
="" calculated="" min="" then="" it="" the
="" current="" in="" hamiltonion="" if(new_circuit_length<="min_circuit_length)
" set_ham_ckt(min_circuit_length="new_circuit_length);
" }
="" any="" found
if(min_circuit_length<infi)
{
="" printf("\n\nminimum="" is:="" %ld\ncircuit="" is:\n",min_circuit_length);
="" printf("<%ld=""> ",ham_circuit[i]);
}
else printf("\n\nNo hamiltonian circuit !");
delete []visited;
delete []min_circuit;
delete []ham_circuit;
}
|
|
|
|
|
What is your question?
Note: I have deleted your duplicate of this post.
|
|
|
|