Discussion:
[Bug-apl] Rational Numbers
Juergen Sauermann
2017-07-20 16:05:03 UTC
Permalink
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="Helvetica, Arial, sans-serif">Hi,<br>
<br>
coming back to a proposal from Elias, I have added (experimental)
support<br>
for rational numbers in GNU APL. <b>SVN 982</b>.<br>
<br>
It has to be enabled explicitly:<br>
<br>
<font face="Courier New, Courier, monospace"><b>./configure
RATIONAL_NUMBERS_WANTED=yes</b></font><br>
<br>
In APL you can display rational numbers by setting <b>⎕PS[1]</b>:<br>
<br>
<font face="Courier New, Courier, monospace"><b>      ⎕PS←0 22</b><b><br>
</b><b>      2÷3</b><b><br>
</b><b>╔════════════╗</b><b><br>
</b><b>║0.6666666667║</b><b><br>
</b><b>╚════════════╝</b><b><br>
</b><b>      ⎕PS←1 22</b><b><br>
</b><b>      2÷3</b><b><br>
</b><b>╔═══╗</b><b><br>
</b><b>║2÷3║</b><b><br>
</b><b>╚═══╝</b></font><br>
<br>
(The second item in <b>⎕PS</b> is a boxing style as in the
]BOXING command).<br>
<br>
Best Regards,<br>
Jürgen<br>
<br>
</font>
</body>
</html>
Elias Mårtenson
2017-07-21 04:06:39 UTC
Permalink
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
Hi,
coming back to a proposal from Elias, I have added (experimental) support
for rational numbers in GNU APL. *SVN 982*.
*./configure RATIONAL_NUMBERS_WANTED=yes*
* ⎕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
Elias Mårtenson
2017-07-21 04:19:50 UTC
Permalink
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.
Post by Elias MÃ¥rtenson
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
Hi,
coming back to a proposal from Elias, I have added (experimental) support
for rational numbers in GNU APL. *SVN 982*.
*./configure RATIONAL_NUMBERS_WANTED=yes*
* ⎕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
Juergen Sauermann
2017-07-23 13:28:27 UTC
Permalink
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="Helvetica, Arial, sans-serif">Hi Elias,<br>
<br>
the format bug is fixed in <b>SVN 983.</b><br>
<br>
Rational numbers are exact, they are stored as a 64 bit numerator
and a 64 bit denominator.<br>
You can convert a rational to a float with monadic +:<br>
<br>
<font face="Courier New, Courier, monospace"><b>      ⎕PS←1 0   ⍝
display quotients</b><b><br>
</b><b>      2÷3</b><b><br>
</b><b>2÷3</b><b><br>
</b><b>      +2÷3</b><b><br>
</b><b>0.6666666667</b><b><br>
</b></font><br>
Normally monadic + is not needed because conversion to double
happens automatically where needed.<br>
<br>
/// Jürgen<br>
<br>
</font><br>
<div class="moz-cite-prefix">On 07/21/2017 06:19 AM, Elias Mårtenson
wrote:<br>
</div>
<blockquote
cite="mid:CADtN0W+***@mail.gmail.com"
type="cite">
<div dir="ltr">There is an error in the rational code:
<div><br>
</div>
<div>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.</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 21 July 2017 at 12:06, Elias
Mårtenson <span dir="ltr">&lt;<a moz-do-not-send="true"
href="mailto:***@gmail.com" target="_blank">***@gmail.com</a>&gt;</span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">I haven't looked at this yet, but is this
purely a display feature, or is it a full implementation
of rational numbers?
<div><br>
</div>
<div>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?</div>
<div><br>
</div>
<div>Regards,</div>
<div>Elias</div>
</div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On 21 July 2017 at 00:05,
Juergen Sauermann <span dir="ltr">&lt;<a
moz-do-not-send="true"
href="mailto:***@t-online.de"
target="_blank">***@t-online.de</a><wbr>&gt;</span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> <font
face="Helvetica, Arial, sans-serif">Hi,<br>
<br>
coming back to a proposal from Elias, I have
added (experimental) support<br>
for rational numbers in GNU APL. <b>SVN 982</b>.<br>
<br>
It has to be enabled explicitly:<br>
<br>
<font face="Courier New, Courier, monospace"><b>./configure
RATIONAL_NUMBERS_WANTED=yes</b></font><br>
<br>
In APL you can display rational numbers by
setting <b>⎕PS[1]</b>:<br>
<br>
<font face="Courier New, Courier, monospace"><b>     
⎕PS←0 22</b><b><br>
</b><b>      2÷3</b><b><br>
</b><b>╔════════════╗</b><b><br>
</b><b>║0.6666666667║</b><b><br>
</b><b>╚════════════╝</b><b><br>
</b><b>      ⎕PS←1 22</b><b><br>
</b><b>      2÷3</b><b><br>
</b><b>╔═══╗</b><b><br>
</b><b>║2÷3║</b><b><br>
</b><b>╚═══╝</b></font><br>
<br>
(The second item in <b>⎕PS</b> is a boxing
style as in the ]BOXING command).<br>
<br>
Best Regards,<br>
Jürgen<br>
<br>
</font> </div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>
Ala'a Mohammad
2017-08-11 13:22:39 UTC
Permalink
Hi Jürgen,

I was playing with experimental support for rational numbers and found
that result was converted to float while using dyadic maximum,
minimum, even though I did not use the monadic +

(1÷3) ⌈ (3÷4)
0.75

(1÷3) ⌊ (3÷4)
0.3333333333

Is this the intended display?

Also by accident, I was playing with the support and the strange
display of the following occurred

÷¯1÷3
3÷18446744073709551615

Entering the above result gives another number

3÷18446744073709551615
1.626303259E¯19

The positive case works better (even though I had expected one digit
display only '3'), but somehow the neg mess-up the display

÷1÷3
3÷1

Regards,

Ala'a

On Sun, Jul 23, 2017 at 5:28 PM, Juergen Sauermann
Post by Juergen Sauermann
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.
⎕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
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.
Post by Elias MÃ¥rtenson
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
Hi,
coming back to a proposal from Elias, I have added (experimental) support
for rational numbers in GNU APL. SVN 982.
./configure RATIONAL_NUMBERS_WANTED=yes
⎕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
Juergen Sauermann
2017-08-11 20:26:45 UTC
Permalink
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="Helvetica, Arial, sans-serif">Hi Ala'a,<br>
<br>
thanks, fixed in<b> SVN 993</b>.</font><br>
<div class="moz-cite-prefix"><br>
/// Jürgen<br>
<br>
On 08/11/2017 03:22 PM, Ala'a Mohammad wrote:<br>
</div>
<blockquote
cite="mid:CAJ--6mZ5jNQ4F3dmJUKkBAgvcYwU1ikqxfd7PbcnjZVMCDob=***@mail.gmail.com"
type="cite">
<pre wrap="">Hi Jürgen,

I was playing with experimental support for rational numbers and found
that result was converted to float while using dyadic maximum,
minimum, even though I did not use the monadic +

(1÷3) ⌈ (3÷4)
0.75

(1÷3) ⌊ (3÷4)
0.3333333333

Is this the intended display?

Also by accident, I was playing with the support and the strange
display of the following occurred

÷¯1÷3
3÷18446744073709551615

Entering the above result gives another number

3÷18446744073709551615
1.626303259E¯19

The positive case works better (even though I had expected one digit
display only '3'), but somehow the neg mess-up the display

÷1÷3
3÷1

Regards,

Ala'a

On Sun, Jul 23, 2017 at 5:28 PM, Juergen Sauermann <a class="moz-txt-link-rfc2396E" href="mailto:***@t-online.de">&lt;***@t-online.de&gt;</a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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 <a class="moz-txt-link-rfc2396E" href="mailto:***@gmail.com">&lt;***@gmail.com&gt;</a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">
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 <a class="moz-txt-link-rfc2396E" href="mailto:***@t-online.de">&lt;***@t-online.de&gt;</a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">
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

</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<pre wrap="">

</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<br>
</body>
</html>
Ala'a Mohammad
2017-08-11 21:55:51 UTC
Permalink
Hi Jürgen,

Thanks go to you for the prompt response. I do really appreciate it.

Regards,

Ala'a

On Sat, Aug 12, 2017 at 12:26 AM, Juergen Sauermann
Post by Juergen Sauermann
Hi Ala'a,
thanks, fixed in SVN 993.
/// Jürgen
Hi Jürgen,
I was playing with experimental support for rational numbers and found
that result was converted to float while using dyadic maximum,
minimum, even though I did not use the monadic +
(1÷3) ⌈ (3÷4)
0.75
(1÷3) ⌊ (3÷4)
0.3333333333
Is this the intended display?
Also by accident, I was playing with the support and the strange
display of the following occurred
÷¯1÷3
3÷18446744073709551615
Entering the above result gives another number
3÷18446744073709551615
1.626303259E¯19
The positive case works better (even though I had expected one digit
display only '3'), but somehow the neg mess-up the display
÷1÷3
3÷1
Regards,
Ala'a
On Sun, Jul 23, 2017 at 5:28 PM, Juergen Sauermann
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.
⎕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
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.
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
Hi,
coming back to a proposal from Elias, I have added (experimental) support
for rational numbers in GNU APL. SVN 982.
./configure RATIONAL_NUMBERS_WANTED=yes
⎕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
Loading...