|
Google "Bit shifting" and how base-2 number systems (uh, dat be called binary ) sometime...
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
If you are trying to multiply integers you can use addition in a loop, but without knowing more about what you want to acheive I do not think anyone here can really help.
Try to explaion why you need to do this and what you are trying to acheive.
Good Luck,
Ali
|
|
|
|
|
Hint: operators + and <<
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 thought building ALUs in circuits class was really fun
|
|
|
|
|
do we get a share of your grade ?
|
|
|
|
|
Try something like this, it's just the same as you do it on paper:
#include "stdafx.h"
#include <iostream>
using namespace std;
unsigned int Multiply(unsigned int l, unsigned int r)
{
unsigned res = 0;
while (l!=0 && r!=0)
{
if (r&1)
{
res += l;
}
l <<= 1;
r >>= 1;
}
return res;
}
int main()
{
cout << "1234 * 2:" << endl;
cout << "\t* = " << 1234*2 << endl;
cout << "\tMultiply = " << Multiply(1234, 2) << endl << endl;
cout << "314159 * 33:" << endl;
cout << "\t* = " << 314159*33 << endl;
cout << "\tMultiply = " << Multiply(314159, 33) << endl << endl;
return 0;
}
Steve
|
|
|
|
|
i have added the following code to create status bar in a dialog.
But its not getting created.
what could be the problem
....
m_StatusBar.Create(this);
m_StatusBar.SetIndicators(indicators, sizeof(indicators)/ sizeof(UINT));
....
|
|
|
|
|
Check this article[^].
BTW, I searched for "dialog status bar" on the codeproject search and that was the first result
|
|
|
|
|
Yes. its good sample.
Meanwhile i am getting the following error.
error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [10]' to 'const wchar_t *'
How to resove this.
|
|
|
|
|
It is because UNICODE is defined for your project. I suggest this excellent article[^] if you want to understand what is happening. If you don't care, just disable UNICODE in your project settings (but you'll miss a chance to learn something usefull).
|
|
|
|
|
Thanks.i gone thru the article.
Look below decl. of unicode.
wchar_t wch = L'1'; // 2 bytes, 0x0031
wchar_t* wsz = L"Hello"; // 12 bytes, 6 wide characters
First stmt one char -> 2Byte.
Second stme five char -> 12 byte. How?
|
|
|
|
|
RSAK wrote: .i gone thru the article.
It seems that you didn't really understand the article . wchar is a wide character, which means each character is coded on two bytes. So, the string "Hello" (with the terminating character) is 6 wide characters so 12 bytes.
BTW, don't use wide characters directly but use TCHAR instead. In this way, your code will support both unicode and non-unicode builds.
|
|
|
|
|
i actually confused with the first stmt as it has one char and another(termin char). so total would come 4 bytes.
|
|
|
|
|
No: it is not a string. It is a single wchar, so its size is 2 bytes.
|
|
|
|
|
Again and again i am struck with unicode and multibyte char convesions.
int iValue = m_iValue1;
CString str;
str.Format("%d", m_iValue);
.....
.....
m_ListBox.AddString(str);
.....
How to do that using TCHAR? like format used in CString..
|
|
|
|
|
|
|
Did you get this resolved? (I just implemented it in about 5 minutes w/ that article)
|
|
|
|
|
|
Hi all,
From VC++ code i am calling a stored procedure that is updating some fields in the data base
the code is working fine for sql2k but throwing following exception for 2k5
Error Message: Multiple-step operation generated errors. Check each status value.
Failed to update column XYZ with value: 1
Column Attributes for Receive_Status: [Field accepts null values][Null values can be read from the field][Field contains fixed-length data]
Field Status for Receive_Status: [Value violated the data source schema constraint for the field]
Please help me here ...
am having a suspect on a variable of stored proc that is used as tinyint ...
please help me here ...
Thanks
vikas da
|
|
|
|
|
tasumisra wrote: Value violated the data source schema constraint for the field
What are the constraints for the column in qustion?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
the onstraints are value for the column xyz cant be null..
vikas da
|
|
|
|
|
Without the schema and the stored procedure it's harder to guess.
Can you post a small example that duplicates the problem?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am calling WM_PRINT to print the control. It is drawing the control but Client area of window is blank. This is my code
LRESULT lRes = InTouch.SendMessage(WM_PRINT,(LPARAM)hDC, PRF_CLIENT | PRF_CHILDREN | PRF_OWNED|PRF_NONCLIENT);
where InTouch is a CWnd parameter.
Any help is appreciated
Regards, Eswari
|
|
|
|
|
subramanyeswari wrote: It is drawing the control but Client area of window is blank
you mean black?How did you create the DC and bitmap?
also did you try PrintWindow() function?
|
|
|
|