From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a30e9cc47b5029fe X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: ratioanl number type Date: 1999/12/11 Message-ID: <82tnk0$n56$1@nnrp1.deja.com>#1/1 X-Deja-AN: 559351566 References: <38473D8A.9BB68676@gte.net> <3847E5B3.B96339A8@iforex.net> <385252FF.BB4C7A5@gte.net> X-Http-Proxy: 1.0 x38.deja.com:80 (Squid/1.1.22) for client 170.1.222.94 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Sat Dec 11 14:37:52 1999 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-12-11T00:00:00+00:00 List-Id: In article <385252FF.BB4C7A5@gte.net>, cnelson9@gte.net wrote: > > > Dmitriy Anisimkov wrote: > > > "Clifford J. Nelson" wrote: > > > > > Are there any Ada95 examples in books or on the web that implement the > > > exact rational number data type, > > > > ....... > > > > > available > > > memory should be the only limit to their size. > > > > Try http://www.chat.ru/~vagul/Unlimit7.zip > > A timing test of GNAT Ada95 CodeBuilder 1.1 exact rational numbers with > unlimited size integers using http://www.chat.ru/~vagul/Unlimit7.zip > compared to Mathematica 3.01. > > Ada95 took 4861.733319000 seconds. Mma took 15.2667 seconds. That's not too surprising. It is very easy to write inefficient exact rational handling, and a naive approach is indeed likely to be far slower than the carefully crafted routines inside Mma, where these operations are of course central to the mission, so a lot of effort has gone into doing things right. Another reminder that choosing the proper algorithms and data structures is usually FAR more important from an efficiency point of view than choice of language! Actually in the case of multiple precision, high level languages are often at a disadvantage compared to machine language for two reasons: 1. They do not give easy access to the carry flag, and operations like add-carry. 2. They do not give easy access to the multiply and divide operations that mix single and double length results. It wouldn't surprise me if Mma used some assembly language insertions at this point, or at the very least, very low level code designed to interface to the machine very carefully. Sent via Deja.com http://www.deja.com/ Before you buy.