bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Rational Numbers


From: Juergen Sauermann
Subject: Re: [Bug-apl] Rational Numbers
Date: Sun, 23 Jul 2017 15:28:27 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

Hi Elias,

the format bug is fixed in SVN 983.

Rational numbers are exact, they are stored as a 64 bit numerator and a 64 bit denominator.
You can convert a rational to a float with monadic +:

      ⎕PS←1 0   ⍝ display quotients
      2÷3
2÷3
      +2÷3
0.6666666667

Normally monadic + is not needed because conversion to double happens automatically where needed.

/// Jürgen


On 07/21/2017 06:19 AM, Elias Mårtenson wrote:
There is an error in the rational code:

In Archive.cc, line 218, the snprintf format is wrong. %lld is used, while the types of the arguments are actually "long". Thus, "%lld÷%lld" should be "%ld÷%ld" instead.

On 21 July 2017 at 12:06, Elias Mårtenson <address@hidden> wrote:
I haven't looked at this yet, but is this purely a display feature, or is it a full implementation of rational numbers?

In other words, is the result of 1÷3 exact? And if so, how do I convert a rational number into a floating-point number?

Regards,
Elias

On 21 July 2017 at 00:05, Juergen Sauermann <address@hidden> wrote:
Hi,

coming back to a proposal from Elias, I have added (experimental) support
for rational numbers in GNU APL. SVN 982.

It has to be enabled explicitly:

./configure RATIONAL_NUMBERS_WANTED=yes

In APL you can display rational numbers by setting ⎕PS[1]:

      ⎕PS←0 22
      2÷3
╔════════════╗
║0.6666666667║
╚════════════╝
      ⎕PS←1 22
      2÷3
╔═══╗
║2÷3║
╚═══╝


(The second item in ⎕PS is a boxing style as in the ]BOXING command).

Best Regards,
Jürgen





reply via email to

[Prev in Thread] Current Thread [Next in Thread]