comp.lang.ada
 help / color / mirror / Atom feed
From: gisle@apal.ii.uib.no (Gisle Sælensminde)
Subject: Re: bignums
Date: 24 Jul 2001 17:51:36 GMT
Date: 2001-07-24T17:51:36+00:00	[thread overview]
Message-ID: <slrn9lrdd8.t30.gisle@apal.ii.uib.no> (raw)
In-Reply-To: 9jk3th$knr$1@news.huji.ac.il

In article <9jk3th$knr$1@news.huji.ac.il>, Ehud Lamm wrote:
>Tomasz Wegrzanowski <taw@pb220.legnica.sdi.tpnet.pl> wrote in message
>news:9jifep$kf0$2@news.tpi.pl...
>> Is there any unlimited-size-integer thing in Ada,
>> something like gmp in C ?
>
>There are two issues here. First, support for bignums: there are some
>package around, and it isn't too hard to hack something.
>The second issue is efficiency. I seem to recall that GMP is highly
>optimized, uses assembly language etc. So one  may actually want or hope for
>a binding to GMP. I don't know a thing about it, but I did find this web
>page http://www.chiark.greenend.org.uk/~mroe/Ada/GMP/. Maybe someone knows
>more about the current status of this.

I also wrote a binding for GMP, and have finished the integer part of it,
including a thick binding, but not for rationals and floats. I had plans 
to develop the rest when I have made the thick binding for floats as 
well, but the project stop since I personally only needed integers, and 
the float stuff seems to be crap, so I stoped there without finishing the 
project. I if anybody are interested I can put the bits together and 
relese it.

There is one problem by making a thick binding for a library like GMP.
Of cause the most natural way of making a thick binding is to use
operator overloading, so that you can make code like "A = B + C;".

The problem is that each new GMP number is dynamically allocated,
and for uing it with operator overloading you must make a controlled 
type and allocate a new new number for each operation. This leads to
very slow code, compared to the thin binding. In my fibonacci test
there were a 1:6 difference between them.

A better Idea then would be to write a new binding where one could use
Ada's capability to allocate the numbers on the stack. I was member of a 
mailing list where we started looking at this, but it ended because 
all of us were having (final) exams at the time.

- Gisle

>
>
>HTH
>
>Ehud Lamm
>
>


-- 
--
Gisle S�lensminde ( gisle@ii.uib.no )   

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going
to land, and it could be dangerous sitting under them as they fly
overhead. (from RFC 1925)



  reply	other threads:[~2001-07-24 17:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-24  0:28 bignums Tomasz Wegrzanowski
2001-07-24  6:36 ` bignums Gerhard Häring
2001-07-24 15:22 ` bignums Ehud Lamm
2001-07-24 17:51   ` Gisle Sælensminde [this message]
2001-07-24 17:59     ` bignums Ehud Lamm
  -- strict thread matches above, loose matches on Subject: below --
2001-07-24 20:16 bignums Gautier Write-only-address
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox