Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Steve Thompson <stevet810@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Large number libraries/algorithms |
| Date | 2012-10-23 12:40 +0000 |
| Organization | Friends of the Galactic Collective |
| Message-ID | <SvMVwi.YsV.f48kV@gmail.com> (permalink) |
| References | (1 earlier) <4q6dnXHstpLfshjNnZ2dnUVZ8o-dnZ2d@lyse.net> <lnk3uifm5x.fsf@nuthaus.mib.org> <vm9b88hl9qirqv7i8pnq5j3un82bvmsnik@4ax.com> <0.4b9d32dea7f57a2ad3b4.20121023000110BST.87ipa29knd.fsf@bsb.me.uk> <wNmdnbKqcMPz1xvNnZ2dnUVZ7oSdnZ2d@lyse.net> |
On Tue, Oct 23, 2012 at 09:38:00AM +0200, David Brown wrote: > On 23/10/2012 01:01, Ben Bacarisse wrote: > >Robert Wessel <robertwessel2@yahoo.com> writes: > > > >>On Mon, 22 Oct 2012 10:31:54 -0700, Keith Thompson <kst-u@mib.org> > >>wrote: > >> > >>>David Brown <david@westcontrol.removethisbit.com> writes: > >>>>On 22/10/2012 11:11, boltar2003@boltar.world wrote: > >>>>>Does anyone know of an API that will do standard math ops (*,+,-,/,% > >>>>>etc) on > >>>>>very large numbers (stored in char arrays presumably)? ie The sort of > >>>>>numbers > >>>>>that have no chance of fitting in even a 64 bit int or double. Or > >>>>>failing > >>>> > >>>>If your numbers will fit into 128-bit ints, then I think it is quite > >>>>common to support 128-bit types in 64-bit compilers, and they will be > >>>>much more efficient than arbitrarily long number libraries. But that > >>>>only helps if 128 bits is big enough. > >>> > >>>I don't think I've ever seen a C compiler that supports 128-bit > >>>integers. Can you provide an example? > >> > >> > >>Doesn't Jacob Navia's? And GCC on 64 bit targets usually has at least > >>partial support. > > > >It supports a type called int128, but it's not an integer type. For > >example, you can't cast it to another integer type. It's implemented as > >a struct using lcc-win32's operator overloading so it's a matter of > >debate if a program using it is using a "C compiler". Jacob's operator > >overloading is deliberately unobtrusive but I have not studied the > >consequences of not using the compiler in a conforming mode. > > > >gcc provides __int128 "for targets having an integer mode wide enough to > >hold 128-bit". I'm not sure exactly what's included in that. > > > > gcc certainly provides it for 64-bit amd64 targets - and I'm guessing > also for other 64-bit targets (such as PPC, MIPS, IA-64). It is treated > much like any other integer type as far as gcc is concerned. Generated > code will use two registers and twice as many operations compared to > 64-bit integers, but that's standard for C compilers working with > integers wider than the registers. > > It would not surprise me unduly if gcc supported 128-bit integers on > 32-bit targets as well (after all, it happily supports 64-bit integers > on 8-bit targets), but I haven't checked. I was briefly looking at the compiler info pages but I could not easily determine whether support included all the trig/exponential/etc math functions or whether it only supports basic arithmetic operations. In the latter case, it doesn't seem like it would be all that useful. Regards, Steve Thompson -- GOTO's are like guns. Safety is entirely contingent on the user.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Large number libraries/algorithms boltar2003@boltar.world - 2012-10-22 09:11 +0000
Re: Large number libraries/algorithms Mark Bluemel <mark_bluemel@pobox.com> - 2012-10-22 10:15 +0100
Re: Large number libraries/algorithms Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-10-22 09:19 +0000
Re: Large number libraries/algorithms boltar2003@boltar.world - 2012-10-22 09:40 +0000
Re: Large number libraries/algorithms Noob <root@127.0.0.1> - 2012-10-22 11:24 +0200
Re: Large number libraries/algorithms David Brown <david@westcontrol.removethisbit.com> - 2012-10-22 13:29 +0200
Re: Large number libraries/algorithms boltar2003@boltar.world - 2012-10-22 11:53 +0000
Re: Large number libraries/algorithms James Kuyper <jameskuyper@verizon.net> - 2012-10-22 08:01 -0400
Re: Large number libraries/algorithms David Brown <david@westcontrol.removethisbit.com> - 2012-10-22 14:41 +0200
Re: Large number libraries/algorithms James Kuyper <jameskuyper@verizon.net> - 2012-10-22 09:36 -0400
Re: Large number libraries/algorithms Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-22 15:12 +0100
Re: Large number libraries/algorithms Keith Thompson <kst-u@mib.org> - 2012-10-22 10:31 -0700
Re: Large number libraries/algorithms Robert Wessel <robertwessel2@yahoo.com> - 2012-10-22 15:09 -0500
Re: Large number libraries/algorithms Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-23 00:01 +0100
Re: Large number libraries/algorithms David Brown <david@westcontrol.removethisbit.com> - 2012-10-23 09:38 +0200
Re: Large number libraries/algorithms Steve Thompson <stevet810@gmail.com> - 2012-10-23 12:40 +0000
Re: Large number libraries/algorithms David Brown <david@westcontrol.removethisbit.com> - 2012-10-23 16:23 +0200
Re: Large number libraries/algorithms Steve Thompson <stevet810@gmail.com> - 2012-10-23 14:38 +0000
Re: Large number libraries/algorithms Keith Thompson <kst-u@mib.org> - 2012-10-23 12:58 -0700
Re: Large number libraries/algorithms David Brown <david@westcontrol.removethisbit.com> - 2012-10-24 09:01 +0200
Re: Large number libraries/algorithms James Kuyper <jameskuyper@verizon.net> - 2012-10-24 07:18 -0400
Re: Large number libraries/algorithms David Brown <david@westcontrol.removethisbit.com> - 2012-10-24 14:23 +0200
Re: Large number libraries/algorithms Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-24 14:43 +0100
Re: Large number libraries/algorithms Keith Thompson <kst-u@mib.org> - 2012-10-24 11:33 -0700
Re: Large number libraries/algorithms Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-24 19:53 +0100
Re: Large number libraries/algorithms James Kuyper <jameskuyper@verizon.net> - 2012-10-24 10:50 -0400
Re: Large number libraries/algorithms Noob <root@localhost> - 2012-10-24 15:16 +0200
Re: Large number libraries/algorithms Noob <root@localhost> - 2012-10-24 18:57 +0200
Re: Large number libraries/algorithms Keith Thompson <kst-u@mib.org> - 2012-10-24 11:43 -0700
Re: Large number libraries/algorithms David Brown <david@westcontrol.removethisbit.com> - 2012-10-25 09:05 +0200
Re: Large number libraries/algorithms Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-22 08:23 -0400
Re: Large number libraries/algorithms tom st denis <tom@iahu.ca> - 2012-10-22 11:40 -0700
Re: Large number libraries/algorithms Keith Thompson <kst-u@mib.org> - 2012-10-22 17:05 -0700
Re: Large number libraries/algorithms tom st denis <tom@iahu.ca> - 2012-10-23 07:10 -0700
Re: Large number libraries/algorithms David Brown <david@westcontrol.removethisbit.com> - 2012-10-22 14:42 +0200
Re: Large number libraries/algorithms Chad <cdalten@gmail.com> - 2012-10-23 14:39 -0700
Re: Large number libraries/algorithms pete <pfiland@mindspring.com> - 2012-10-24 03:27 -0400
csiph-web