Click here to Skip to main content
16,006,065 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: integer arithmetic Pin
Anonymous1-May-05 11:36
Anonymous1-May-05 11:36 
GeneralRe: integer arithmetic Pin
Christian Graus1-May-05 11:46
protectorChristian Graus1-May-05 11:46 
GeneralRe: integer arithmetic Pin
Anonymous1-May-05 18:10
Anonymous1-May-05 18:10 
GeneralRe: integer arithmetic Pin
Christian Graus1-May-05 18:16
protectorChristian Graus1-May-05 18:16 
GeneralRe: integer arithmetic Pin
Anonymous1-May-05 19:45
Anonymous1-May-05 19:45 
GeneralRe: integer arithmetic Pin
Christian Graus2-May-05 12:54
protectorChristian Graus2-May-05 12:54 
GeneralRe: integer arithmetic Pin
Anonymous1-May-05 18:11
Anonymous1-May-05 18:11 
GeneralRe: integer arithmetic Pin
ddmcr1-May-05 22:28
ddmcr1-May-05 22:28 
you may use some class derived from CString class.
then you can perform arithmetic operations on them without using vectors, or arrays. ex:

CMyClass s1,s2;
s1="123434";
s2="654321";
//now add them like this
// 123434
// + 654321
// result : 777755

we add them simply like we do it on paper , we read symbols(from the end) from s1 and s2 , for example first we'd add 4 and 1 and get 5.next we'd add 3 and 2 and get 5 and so on...

programatically you can do it like this

CString Add(CString s1,CString s2)
{

CString result,m;
int l1,l2,l,k1,k2,k,temp,g1,g2;
k=temp=k1=k2=0;
m="";

if((s1=="0")&&(s2=="0")) return "0"; // 0+0 = 0

l1=s1.GetLength();
l2=s2.GetLength();
l=__max(l1,l2);

g1=convert(s1,l+1);
g2=convert(s2,l+1);

//convert means if you must add
//123 and 45555 it must convert 123 to 00123
//it's simple to write such function

for(int i=l;i>=0;i--)
{
k1=g1.GetAt(i)-'0';
k2=g2.GetAt(i)-'0';
k=k1+k2+temp;
if(k>=10){k=k-10;temp=1;}else temp=0;
m.Format("%d",k);
result=m+result;
}

return NoZero(result);

//NoZero means if the result is 00987 ir must return 987
}you can modify this function so that it will work with negative number also.

you'll have to do similatly with -,*,/ of course with division job will be harder.

Good luck.

m0n0
Generalsystem command Pin
picasso21-May-05 9:26
picasso21-May-05 9:26 
GeneralRe: system command Pin
mark novak1-May-05 9:31
mark novak1-May-05 9:31 
GeneralRe: system command Pin
ThatsAlok1-May-05 19:16
ThatsAlok1-May-05 19:16 
Generalproblem>> java server & vc++ client Pin
Member 17623431-May-05 9:14
Member 17623431-May-05 9:14 
Generalconvert inches,feet to centimetrs--and throw exceptions etc.... Pin
John K......1-May-05 8:50
John K......1-May-05 8:50 
GeneralRun executable from C++ Pin
Anonymous1-May-05 7:00
Anonymous1-May-05 7:00 
GeneralRe: Run executable from C++ Pin
Andrew Kirillov1-May-05 8:40
Andrew Kirillov1-May-05 8:40 
GeneralRe: Run executable from C++ Pin
picasso21-May-05 9:28
picasso21-May-05 9:28 
GeneralRe: Run executable from C++ Pin
ThatsAlok2-May-05 23:10
ThatsAlok2-May-05 23:10 
GeneralWindows media player Pin
azmina1-May-05 6:57
azmina1-May-05 6:57 
GeneralRe: Windows media player Pin
Christian Graus1-May-05 11:20
protectorChristian Graus1-May-05 11:20 
Questionget winhttp server using HINTERNET handle? Pin
ThinkingPrometheus1-May-05 5:08
ThinkingPrometheus1-May-05 5:08 
QuestionRichEdit for non MFC? Pin
DKT_1-May-05 1:05
DKT_1-May-05 1:05 
AnswerRe: RichEdit for non MFC? Pin
mark novak1-May-05 2:17
mark novak1-May-05 2:17 
GeneralRe: RichEdit for non MFC? Pin
DKT_1-May-05 2:21
DKT_1-May-05 2:21 
GeneralRe: RichEdit for non MFC? Pin
ThatsAlok2-May-05 23:12
ThatsAlok2-May-05 23:12 
Questionhow to write a multichat application !!!!??? Pin
khiconbmt1-May-05 0:40
khiconbmt1-May-05 0:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.