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 <loke...@gmail.com> 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 <juergen.sauerm...@t-online.de> 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