home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- From: nikki@trmphrst.demon.co.uk (Nikki Locke)
- Path: sparky!uunet!pipex!demon!trmphrst.demon.co.uk!nikki
- Subject: Efficient 64-bit integer arithmetic
- Distribution: world
- Organization: Trumphurst Ltd.
- Lines: 28
- Date: Fri, 24 Jul 1992 10:04:18 +0000
- Message-ID: <711997458snx@trmphrst.demon.co.uk>
- Sender: usenet@gate.demon.co.uk
-
- I need to implement efficient 64-bit signed integer arithmetic in C++ (or C)
- on a machine with a 32-bit long (actually, 60 significant bits + sign
- would do fine).
-
- I need addition, subtraction, multiplication, division, remainder, and
- efficient multiply and divide by 10 (for conversion to/from strings).
-
- I have looked at the bignum package, which implements arbitrary precision,
- but I feel the extra constraint of having only 60 significant bits should
- enable a much more efficient implementation to be possible.
-
- Does anyone know of any such code available for anonymous ftp ? Or have
- any suggestions ?
-
- I have a reasonably efficient add, subtract and multiply, (though no doubt
- some of the number theorists here could improve them significantly), but
- the divide is currently accomplished by a full 64-bit rotate/subtract
- loop, which I found much faster than the bignum method of estimating the
- answer using floating point. This is almost certainly because I didn't
- have an FP chip in my machine at the time, but I don't want to have to
- insist on an FP chip for acceptable performance.
-
- Thanks in advance,
-
- ---
- Nikki Locke | | nikki@trmphrst.demon.co.uk
- Trumphurst Ltd. | Tel: +44 (0)691-670318 | nikki@cix.compulink.co.uk
- PC and Unix consultancy | Fax: +44 (0)691-670316 | nikki@kewill.co.uk
-