| www.delorie.com/archives/browse.cgi | search |
| Message-ID: | <3D8EA8B0.F4EA56@yahoo.com> |
| From: | CBFalconer <cbfalconer AT yahoo DOT com> |
| Organization: | Ched Research |
| X-Mailer: | Mozilla 4.75 [en] (Win98; U) |
| X-Accept-Language: | en |
| MIME-Version: | 1.0 |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: Problem with multiplications |
| References: | <M2%i9.25731$Av4 DOT 488132 AT twister2 DOT libero DOT it> |
| Lines: | 27 |
| Date: | Mon, 23 Sep 2002 14:51:39 GMT |
| NNTP-Posting-Host: | 12.90.173.92 |
| X-Complaints-To: | abuse AT worldnet DOT att DOT net |
| X-Trace: | bgtnsc05-news.ops.worldnet.att.net 1032792699 12.90.173.92 (Mon, 23 Sep 2002 14:51:39 GMT) |
| NNTP-Posting-Date: | Mon, 23 Sep 2002 14:51:39 GMT |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Carlo Bramini wrote: > > I have a problem with DJGPP, but I'm going to think it's common with all > i386 target versions of this compiler. > I have two 32 bit numbers and I want to do: > > c = (a*b) >> 32; > > for getting the upper 32 bit DWORD. > Unfortunately, it doesn't work! ... snip ... You need to ensure your numbers never overflow a 32 bit value. So break the input up into 16 bit components, so that a = (a1 << 16) + a2 and b = (b1 << 16) + b2, and do your arithmetic on the 16 bit components. You will have to devise a way of combining them into a 64 bit value, which will probably be some sort of byte array. Watch out for signs. An easier method is to just use a bignum package. -- Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net) Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net> USE worldnet address!
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |