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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Fun with Unbounded Rational Numbers Date: Sat, 8 Apr 2017 12:37:43 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 8 Apr 2017 10:34:42 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="52d1b398f8068cd3a2be391a9bd818f8"; logging-data="10265"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vluuDlX5e9tp9f2GrIC1ISNPh4y2EAeM=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 X-Mozilla-News-Host: news://news.eternal-september.org:119 Cancel-Lock: sha1:IiFERz22AwWW5ZrhxR5BUCf2eaw= Xref: news.eternal-september.org comp.lang.ada:46542 Date: 2017-04-08T12:37:43+02:00 List-Id: I decided to see what happens when you calculate square roots using Newton's method and the unbounded rational numbers in PragmARC.Rational_Numbers. Some interesting things happen. For example, trying to calculate sqrt(2) to a small enough accuracy (0.000001 will do it) results in the calculation of the next estimate M := Two * X; X := X - Y / M; taking a Long Time (it does conclude eventually). More alarming, though, is that for some values, even a fairly large accuracy will quickly result in Storage_Error. For example, sqrt(1.28) to an accuracy of 0.01 will do it. I realize that square roots are often irrational, but the accuracies seem so large that I didn't anticipate consuming GB of memory. Just naive, I guess. -- Jeff Carter "C++ is vast and dangerous, a sort of Mordor of programming languages." Jason R. Fruit 120