<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 Fred,<br>
<br>
Rational. and non-rational numbers use the same Cell type
(FloatCell).<br>
</font><br>
Non-Rational numbers have a <b>denominator = 0</b> and store their
value in <b>value.fval.u1.flt</b> (which is a <b>double</b> in
union <b>u1</b>)<br>
Rational numbers have a <b>denominator >= 1</b> and store their
value in <b>value.fval.u1.num (</b>which is an <b>int64_t</b> in
union <b>u1</b>)<br>
<br>
So basically a rational number uses the same space that a complex
number would use for its imaginary part (to avoid an<br>
increase of the Cell size by introducing rational numbers).<br>
<br>
<b>26 ⎕CR </b>has nothing to do with all of this.<br>
<b>27 ⎕CR</b> returns the primary value of a Cell (which is always
an integer that was possibly cast from a different type like<br>
APL_Char or APL_Float to APL_Integer = int64_t).<br>
<b>28 ⎕CR </b>is 0 or the secondary value of a Cell (imaginary part
for Complex Cells, Denominator for Rational FloatCells, ...),<br>
and is also always an APL_Integer.<br>
<br>
<font face="Courier New, Courier, monospace"><b> 28 ⎕CR ÷ 2</b><b><br>
</b><b>2</b></font><br>
<br>
So the denominator is NOT represented by a <b>double</b> but by an
<b>int64_t</b>.<br>
<br>
The idea behind <b>27/28 ⎕CR</b> is to get the underlying machine
representation of the value(s) store in a Cell (similar to dyadic <b>⎕CR</b><br>
in good old APL68000) which by chance is the denominator of a
rational float value.<br>
<br>
Hope that explains it,<br>
<br>
/// Jürgen<br>
<br>
<br>
<div class="moz-cite-prefix">On 08/30/2017 07:59 AM, Frederick Pitts
wrote:<br>
</div>
<blockquote cite="mid:***@comcast.net"
type="cite">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<div>Hello Jürgen,</div>
<div><br>
</div>
<div> After reading your email and the apl.html documentation on
⎕CR and so, I've have two questions:</div>
<div><br>
</div>
<div> 1) How does one know B is a rational number? The apl.html
documentation for 26 ⎕CR B does not show</div>
<div>that there is a cell type for rationals and I could not
locate one in the source code. Admittedly my examination was
cursory. </div>
<div> 2) Why is a real number being used to represent the
numerator of a rational number? I thought ~63-bit</div>
<div>integers would consistently be used to represent the parts of
a rational. 26 ⎕CR ÷ 2 yields 32 indicating that 1 is being
represented by a real rather than an integer. That is puzzling
to me. It almost seems irrational, no pun intended.</div>
<div><br>
</div>
<div>Regards.</div>
<div><br>
</div>
<div><br>
</div>
<div>On Tue, 2017-08-29 at 12:51 +0200, Juergen Sauermann wrote:</div>
<blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px
#729fcf solid;padding-left:1ex"> <font face="Helvetica, Arial,
sans-serif">Hi Fred,<br>
<br>
the existing mechanism is <b>27 ⎕CR</b> B to get the
numerator of B and <b>28 ⎕CR</b> to get the denominator <b>>
0</b><br>
of a quotient or 0 if the number is not a quotient (and then <b>27
</b><b>⎕CR</b> is the<b> double B</b> cast to </font><font
face="Helvetica, Arial, sans-serif"><b>uint64</b></font><font
face="Helvetica, Arial, sans-serif"><b>_t</b>.<br>
<br>
Unfortunately there was a bug <b>28 ⎕CR</b> returning always
<b>0</b>. Fixed in<b> SVN 1004</b>.<br>
</font><br>
Best Regards,<br>
/// Jürgen<br>
<br>
<br>
<div class="moz-cite-prefix">On 08/28/2017 11:24 PM, Frederick
Pitts wrote:<br>
</div>
<blockquote cite="mid:***@comcast.net"
type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf
solid;padding-left:1ex">
<pre wrap="">Hello,
Is there an existing mechanism for accessing rational number
numerator and denominator parts analogous to that for accessing complex
number real and imaginary parts? If yes, please let me know how. If
no, can a mechanism be implemented?
Respectfully,
Fred
</pre>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>