comp.lang.ada
 help / color / mirror / Atom feed
* Re: Very big Integers
  1999-04-23  0:00 Very big Integers Denny
@ 1999-04-23  0:00 ` Samuel Mize
  1999-04-24  0:00   ` bglbv
  1999-04-26  0:00 ` Dmitri Anisimkov
  1999-05-04  0:00 ` Vincent P. Amiot
  2 siblings, 1 reply; 9+ messages in thread
From: Samuel Mize @ 1999-04-23  0:00 UTC (permalink / raw)
  To: denny, smize

Denny <vrandezo@trick.informatik.uni-stuttgart.de> wrote:
> I'd like to know, if there is any possibility to use natural numbers
> bigger than Integer'LAST, to print them on the screen and to calculate
> with them (add, subtract, power, multiplicate)...
> 
> Something like
> 
> subtype Big_Natural is Very_Long_Integer range 0..2**100 (about, the
> bigger the better)

It's possible, but unlikely, that your compiler supports them.  Just
make it a new type instead of a subtype, i.e. make the declaration:

  type Big_Natural is range 0 .. 2**100;

and see if it compiles.

If not, you'll have to build your own type.  There may be some
huge-number packages around, check the repositories you can
links to via http://www.adahome.com or http://www.acm.org/sigada .

If you can't find one, it shouldn't be too hard to build a new type.

Best,
Sam Mize

-- 
Samuel Mize -- smize@imagin.net (home email) -- Team Ada
Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Very big Integers
@ 1999-04-23  0:00 Denny
  1999-04-23  0:00 ` Samuel Mize
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Denny @ 1999-04-23  0:00 UTC (permalink / raw)



Hi,

I'd like to know, if there is any possibility to use natural numbers
bigger than Integer'LAST, to print them on the screen and to calculate
with them (add, subtract, power, multiplicate)...

Something like

subtype Big_Natural is Very_Long_Integer range 0..2**100 (about, the
bigger the better)

Help would be appreciated...

yours, denny

--
Denny Vrandecic, stud.inf.
denny@earthling.net





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Very big Integers
  1999-04-23  0:00 ` Samuel Mize
@ 1999-04-24  0:00   ` bglbv
  1999-04-25  0:00     ` Robert Dewar
  1999-04-25  0:00     ` Matthew Heaney
  0 siblings, 2 replies; 9+ messages in thread
From: bglbv @ 1999-04-24  0:00 UTC (permalink / raw)


Samuel Mize <smize@imagin.net> writes:

> make it a new type instead of a subtype, i.e. make the declaration:
> 
>   type Big_Natural is range 0 .. 2**100;
> 
> and see if it compiles.

Indeed, direct support for 100-bit integers is rare nowadays.
On some platforms, 128-bit floating point may come close to the
required 100 bits of mantissa. (In fact, on an IEEE machine it
should have slightly more than that. But the "100" probably wasn't
meant literally.)

> If not, you'll have to build your own type.  There may be some
> huge-number packages around, check the repositories you can
> links to via http://www.adahome.com or http://www.acm.org/sigada .

Also check out mpfun from netlib. It's in Fortran, but package
Interfaces.Fortran is your friend.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Very big Integers
  1999-04-24  0:00   ` bglbv
@ 1999-04-25  0:00     ` Robert Dewar
  1999-04-29  0:00       ` bglbv
  1999-04-25  0:00     ` Matthew Heaney
  1 sibling, 1 reply; 9+ messages in thread
From: Robert Dewar @ 1999-04-25  0:00 UTC (permalink / raw)


In article <87676lsl2h.fsf@bglbv.my-dejanews.com>,
  bglbv@my-dejanews.com wrote:

>  128-bit floating point may come close to the
> required 100 bits of mantissa. (In fact, on an IEEE
> machine it
> should have slightly more than that. But the "100"
> probably wasn't meant literally.)

There is no such requirement or recommendation in either
IEEE754 or IEEE854. For example, a format which was
80-bit Intel expanded to 128 bits by adding 48 bits
required to be all zeroes would be a legitimate
implementation of extended, and in any case extended
precision is not required!


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Very big Integers
  1999-04-24  0:00   ` bglbv
  1999-04-25  0:00     ` Robert Dewar
@ 1999-04-25  0:00     ` Matthew Heaney
  1999-04-29  0:00       ` bglbv
  1 sibling, 1 reply; 9+ messages in thread
From: Matthew Heaney @ 1999-04-25  0:00 UTC (permalink / raw)


bglbv@my-dejanews.com writes:

> Also check out mpfun from netlib. It's in Fortran, but package
> Interfaces.Fortran is your friend.

Can you be more specific about the URLs?  What is netlib, and where is
it?






^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Very big Integers
  1999-04-23  0:00 Very big Integers Denny
  1999-04-23  0:00 ` Samuel Mize
@ 1999-04-26  0:00 ` Dmitri Anisimkov
  1999-05-04  0:00 ` Vincent P. Amiot
  2 siblings, 0 replies; 9+ messages in thread
From: Dmitri Anisimkov @ 1999-04-26  0:00 UTC (permalink / raw)
  To: vrandezo

  Denny <vrandezo@trick.informatik.uni-stuttgart.de> wrote:
> I'd like to know, if there is any possibility to use natural numbers
> bigger than Integer'LAST

You can try http://www.chat.ru/~vagul/Unlimit7.zip .

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Very big Integers
  1999-04-25  0:00     ` Matthew Heaney
@ 1999-04-29  0:00       ` bglbv
  0 siblings, 0 replies; 9+ messages in thread
From: bglbv @ 1999-04-29  0:00 UTC (permalink / raw)


Matthew Heaney <matthew_heaney@acm.org> writes:

> > Also check out mpfun from netlib. It's in Fortran, but package
> > Interfaces.Fortran is your friend.
> 
> Can you be more specific about the URLs?  What is netlib, and where is
> it?

Sorry, I compose my news postings offline, which makes it a little
harder to check such things on the fly. I think the master WWW site
is at http://netlib.org (possibly with a leading www., but I seem
to recall that they don't follow that convention). Certainly there
are pointers to it at http://gams.nist.gov . There are also several
mirrors around the world.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Very big Integers
  1999-04-25  0:00     ` Robert Dewar
@ 1999-04-29  0:00       ` bglbv
  0 siblings, 0 replies; 9+ messages in thread
From: bglbv @ 1999-04-29  0:00 UTC (permalink / raw)


Robert Dewar <robert_dewar@my-dejanews.com> writes:

> >  128-bit floating point may come close to the
> > required 100 bits of mantissa. (In fact, on an IEEE
> > machine it
> > should have slightly more than that. But the "100"
> > probably wasn't meant literally.)
> 
> There is no such requirement or recommendation in either
> IEEE754 or IEEE854. For example, a format which was
> 80-bit Intel expanded to 128 bits by adding 48 bits
> required to be all zeroes would be a legitimate
> implementation of extended, and in any case extended
> precision is not required!

I said "should", not "ought to" or "must". The intended
connotation was one of mere likelihood.

It is customary (whether it's actually mandated/recommended
by the IEEE standards is besides my point) to have:
 32-bit FP:  8-bit exponent, 24-bit mantissa (including implicit leading 1)
 64-bit   : 11-bit exponent, 53-bit mantissa

A reasonable extrapolation *for those platforms that provide an
effective 128-bit floating point type* (that excludes "80-bit with
padding", and I'll grant you that not all platforms support 128-bit FP),
either in hardware or in software, is for such a data type to have
approximately 2*53=106 bits of mantissa (give or take a few bits).
That's all I meant by my remark. If the requirement
is for 100-bit integers, then a typical 128-bit floating point format
is likely to fit the bill. Such a format is not available
on all platforms, and atypical formats are certainly possible.

Note that my extrapolation is more conservative than "14-bit exponent,
114-bit mantissa" because vendors have been known to sacrifice a few
bits for the added simplicity of using a pair of standard 64-bit floats 
and the hardware instructions that go with them.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Very big Integers
  1999-04-23  0:00 Very big Integers Denny
  1999-04-23  0:00 ` Samuel Mize
  1999-04-26  0:00 ` Dmitri Anisimkov
@ 1999-05-04  0:00 ` Vincent P. Amiot
  2 siblings, 0 replies; 9+ messages in thread
From: Vincent P. Amiot @ 1999-05-04  0:00 UTC (permalink / raw)


Some 8 years ago I implemented an embryo of RSA that needed big numbers and
a "modular exponentiation" (you have to perform modulus op on the
exponentiation as you go to prevent you from having to deal with
untractably large numbers).

At the time I used limited private taht were bit arrays in little endian
configuration, so the INT was actually:

	type Int is array (0..Size-1) of Boolean;
	pragma Pack (Int);  

where Size could be a generic formal parameter or a constant.

Besides the 4 basic binary ops (+,-,*,/), the unary ops (+,-), the
comparisons, you will need another basic operation: the numeric litteral...

It can be elegantly provided as:

	function "+" (Left: String) return Int;

to be used as follows:

	X : Int := +"12345678901234567890";

(of course raise constraint error if somebody tries to feed in a string
that contains non-numerical chars...)

Hope this helps
Get back to me if you need further help
Vincent Amiot
Principal Consultant / Aonix  

Denny <vrandezo@trick.informatik.uni-stuttgart.de> wrote in article
<Pine.GSO.4.10.9904231559080.7427-100000@tick.informatik.uni-stuttgart.de>..




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1999-05-04  0:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-23  0:00 Very big Integers Denny
1999-04-23  0:00 ` Samuel Mize
1999-04-24  0:00   ` bglbv
1999-04-25  0:00     ` Robert Dewar
1999-04-29  0:00       ` bglbv
1999-04-25  0:00     ` Matthew Heaney
1999-04-29  0:00       ` bglbv
1999-04-26  0:00 ` Dmitri Anisimkov
1999-05-04  0:00 ` Vincent P. Amiot

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