|
Thanks. But I think it is better to go with SQL. Do you use such any...
I appreciate your help all the time...
Eranga
|
|
|
|
|
Hello everyone...
Good day to you....
Is there any way to dynamically mask a group of bits to retrieve certain values from them?
0000 0000 0000 0000 0000 0000 0000 0001 0000 0000 0111 0010 0001
MSB LSB
There are a total of 52 bits .
Now there is a variable say "x" depending on which I should divide this bits to calculate two values.
I am using shift operators and masking to get this job done.
Suppose x is 20
0000 0000 0111 0010 0001 would give me the first value and
0000 0000 0000 0000 0000 0000 0000 0001 would give me the second value.
I am able to do it only for a predefined value for x i.e only for 20.
I have to mask these 52 bits in such a way that I am able to get the answer for the varying vlaues of x.
Is there a way to do this anyway.
Please help me if anyone knows to do this.
Thanks
cyjoy
|
|
|
|
|
u mean, you want to return first x bits in value 1 and remaining 52-x bits in value 2 right?
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
Yes you are correct..
If you could let me know how to do it.
thank you
cyjoy
|
|
|
|
|
give me few minutes iam working on it.
and is your variable a 64 bit integer?
---------------------------------------
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
and here is what you require.
UINT64 value,value1,value2,maskval;
maskval=0xfffffffffffffff;//assigning the 8 byte integer to all 1s.
maskval=maskval<<x;<i>//x is the number of bits you want to mask.
maskval=~maskval;//toggling the bits from 0 to 1 and vice versa.
value1=value&maskval;
value2=value>>x;
----------------------------------------
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
Thank you very much for your help.
I ll be obliged if you could illustrate me with the example which I have mentioned on my question.
0000 0000 0000 0000 0000 0000 0000 0001 0000 0000 0111 0010 0001
MSB LSB
There are a total of 52 bits .
Now there is a variable say "x" depending on which I should divide this bits to calculate two values.
|
|
|
|
|
Try coding it and giving a few values to X while debugging or printing them in the screen to know if adapt to your needs
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
I ll do it....
Thanks ..
|
|
|
|
|
why not, definitely.
value=0000 0000 0000 0000 0000 0000 0000 0001 0000 0000 0111 0010 0001
first, you will define a maskval with all 1s.
1111 1111 1111 1111 ........upto 64 bits.
then, shift the bits left, x many number of times.
for example, if x is 6, the lsb portion of ur maskval looks like this
1111 1111 1100 0000
if you not this value,
1 s become 0s and 0 s become 1s. something like this
0000 .......0000 0000 0011 1111.
now if you and this maskval with ur original val, then
first 6 bits will get filtered into value1.
to get value 2 right shift ur actual value by x bits.
thats it.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
You are wonderful
That was of great help.
I ll defenitely get back to you if I need any further assistance...
Hope you ll help me
Thanks a lot.....
Have a nice day..
Happy computing.
cyjoy
|
|
|
|
|
cydd wrote: You are wonderful
That was of great help.
thank you.
cydd wrote: I ll defenitely get back to you if I need any further assistance...
Hope you ll help me
sure. with pleasure.
but what about the suggestion i have made.
please make it a habbit.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
hi,
I have a server and client application, which are running on different machines and communicating each other thru sockets. Its using TCP sockets, for which i am using Win32 APIs(WSAStartup, socket, bind, send etc.). I am sending text data from client to server periodically, at a rate of 50 ms. When i run both client and server in one machine, the sending and receival are proper. But when i run them on different machines, sending and receival are not synchronized. When i display the buffer after a receival operation at the server end, it shows same data appended to itself several times. I guess this problem is bcoz the rate of sending and receival are not the same, or the network delay.
All ur suggestions are most welcome..
Thanks in advance,
SYAMLAL
|
|
|
|
|
How are you reading the incoming data exactly ? You need to supply the number of bytes you want to read when you call the recv function. So, in order to read only one message, read only the size of the message. If it is variable, then the best way to do it would be to send the size of the message before the message. You read the size (1, 2 or 4 bytes, depending of the maximum size of your packet) and then you read exactly that number of bytes to get your packet.
|
|
|
|
|
Is Single Thread is dealing with every thing or there are multiple client thread!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Are you using a synchronous or an asynchronous socket?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
SyamlalS wrote: sending and receival are not synchronized.
If you need them synchronized then you have to develop a protocol and processor for the protocol, you don't get that for free with TCP. All TCP does is guarantee the packet order. If your statement accurately describes your problem you could use a finite state machine.
|
|
|
|
|
hello to all,
right now i am doing a project in which i have created two new view classes, other than regular view class which gets created at the time of creating ur application.Lets say those two view classes are "CA1View" and "CB1View" and after that i followed a general method for print previewing which we normally follows i.e created a view class "CReportPreview" which has a base class as "CPreviewView" and wrote methods in it which contains the code of previewing, when i access A1View then i destroy B1View and viceversa, now to get an idea where i am getting error plz refer following code,
In "CA1View" class,
CPrintPreviewState::CPrintPreviewState()
{
// set defaults
nIDMainPane = AFX_IDW_PANE_FIRST;
//nIDMainPane = 1 ;
dwStates = AFX_CONTROLBAR_MASK(AFX_IDW_STATUS_BAR);
// status bar visible if available
hMenu = NULL;
pViewActiveOld = NULL;
//hAccelTable = NULL;
}
void CA1View::OnPrintPreview()
{
CPrintPreviewState* pState = new CPrintPreviewState;
// get default print info
if(!DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, this,
RUNTIME_CLASS(CReportPreview), pState))
{
// In derived classes, reverse special window handling here for
// Preview failure case.
TRACE0("Error: DoPrintPreview failed.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
delete pState; // Preview failed to initialize, delete State
}
// CView::OnFilePrintPreview();
}
--------------------------------------------------------------------------
In "CB1View" class,
CPrintPreviewState::CPrintPreviewState()
{
// set defaults
nIDMainPane = AFX_IDW_PANE_FIRST;
//nIDMainPane = 1 ;
dwStates = AFX_CONTROLBAR_MASK(AFX_IDW_STATUS_BAR);
// status bar visible if available
hMenu = NULL;
pViewActiveOld = NULL;
//hAccelTable = NULL;
}
void CB1View::OnPrintPreview()
{
CPrintPreviewState* pState = new CPrintPreviewState;
// get default print info
if(!DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, this,
RUNTIME_CLASS(CReportPreview), pState))
{
// In derived classes, reverse special window handling here for
// Preview failure case.
TRACE0("Error: DoPrintPreview failed.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
delete pState; // Preview failed to initialize, delete State
}
// CView::OnFilePrintPreview();
}
but when i rebuild the code i get following linker errors,
1)
B1View.obj : error LNK2005: "public: __thiscall CPrintPreviewState::CPrintPreviewState(void)" (??0CPrintPreviewState@@QAE@XZ) already defined in A1View.obj
2)
B1View.obj : error LNK2005: "public: int __thiscall CView::DoPrintPreview(unsigned int,class CView *,struct CRuntimeClass *,struct CPrintPreviewState *)" (?DoPrintPreview@CView@@QAEHIPAV1@PAUCRuntimeClass@@PAUCPrintPreviewState@@@Z
) already defined in A1View.obj
3)
Debug/Program.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
what to do? can any body help me plz its urgent plz
Thanks and Regards,
Anay
|
|
|
|
|
Mmm, you are giving the same name to functions in different classes, because of that comes the linker error.
If you need to know which class is calling the preview... why don't you code the functions in just one place and pass a parameter to specify who is calling the function? With this, the error you are having should not come anymore.
By the way... Are you in Win32 - MFC?? Because you already have printing support by default there.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Nelek wrote: By the way... Are you in Win32 - MFC??
Did you miss the use of TRACE0 , AfxMessageBox , CView , and RUNTIME_CLASS ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
mmmm, maybe yes...
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Nelek wrote: mmmm, maybe yes...
he he he what about OutputDebugString
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You have a default constructor for CPrintPreviewState in two .cpp files. Why?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello Friends,
Is there any way we can make the main thread sleep from within the another user created theread.
I am using the code like below
void fun(void)
{
...
...
if(Some Condition)
{
CreateThread(0, 0, ( LPTHREAD_START_ROUTINE ) ThreadProc, 0, 0, 0 );
DialogBox(...);
}
if (Some Other condition)
{
}
}
void ThreadProc(void)
{
fun();
}
-- modified at 6:01 Wednesday 17th October, 2007
|
|
|
|
|
GauranG33 wrote: from within the another user created theread
WTF are you trying to say here ?!
|
|
|
|