Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #27571

Re: Large number libraries/algorithms

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.supernews.com!news.supernews.com.POSTED!not-for-mail
NNTP-Posting-Date Tue, 23 Oct 2012 07:45:40 -0500
From Steve Thompson <stevet810@gmail.com>
Newsgroups comp.lang.c
Subject Re: Large number libraries/algorithms
Date Tue, 23 Oct 2012 12:40:48 +0000
Organization Friends of the Galactic Collective
Message-ID <SvMVwi.YsV.f48kV@gmail.com> (permalink)
References <k632k0$v5$1@speranza.aioe.org> <4q6dnXHstpLfshjNnZ2dnUVZ8o-dnZ2d@lyse.net> <lnk3uifm5x.fsf@nuthaus.mib.org> <vm9b88hl9qirqv7i8pnq5j3un82bvmsnik@4ax.com> <0.4b9d32dea7f57a2ad3b4.20121023000110BST.87ipa29knd.fsf@bsb.me.uk> <wNmdnbKqcMPz1xvNnZ2dnUVZ7oSdnZ2d@lyse.net>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
User-Agent NN 6.4.3
Lines 65
X-Trace sv3-zgZWZ8+EvKeWi/h0xoArvYcHyOZ5Wcj9c90UnElQs8QlUFFT73VkCnpjE0tn3akKGcn4m4dnIftE6kZ!VJzn/yhwTefTiyh4lT9lGq7qTxdldjvAkG9QbQMPxzUMy1qj2MjonRBMcVnZmQ==
X-Complaints-To www.supernews.com/docs/abuse.html
X-DMCA-Complaints-To www.supernews.com/docs/dmca.html
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 4022
Xref csiph.com comp.lang.c:27571

Show key headers only | View raw


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


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