Hi Fred, Rational. and non-rational numbers use the same Cell type (FloatCell). Non-Rational numbers have a denominator = 0 and store their value in value.fval.u1.flt (which is a double in union u1) Rational numbers have a denominator >= 1 and store their value in value.fval.u1.num (which is an int64_t in union u1) So basically a rational number uses the same space that a complex number would use for its imaginary part (to avoid an increase of the Cell size by introducing rational numbers). 26 ⎕CR has nothing to do with all of this. 27 ⎕CR returns the primary value of a Cell (which is always an integer that was possibly cast from a different type like APL_Char or APL_Float to APL_Integer = int64_t). 28 ⎕CR is 0 or the secondary value of a Cell (imaginary part for Complex Cells, Denominator for Rational FloatCells, ...), and is also always an APL_Integer. 28 ⎕CR ÷ 2 2 So the denominator is NOT represented by a double but by an int64_t. The idea behind 27/28 ⎕CR is to get the underlying machine representation of the value(s) store in a Cell (similar to dyadic ⎕CR in good old APL68000) which by chance is the denominator of a rational float value. Hope that explains it, /// Jürgen On 08/30/2017 07:59 AM, Frederick Pitts
wrote:
|
- [Bug-apl] Access to rational number numerator and denomi... Frederick Pitts
- Re: [Bug-apl] Access to rational number numerator a... Louis de Forcrand
- Re: [Bug-apl] Access to rational number numerat... Frederick Pitts
- Re: [Bug-apl] Access to rational number num... Elias Mårtenson
- Re: [Bug-apl] Access to rational number... Christian Robert
- Re: [Bug-apl] Access to rational n... Elias Mårtenson
- Re: [Bug-apl] Access to ration... Frederick Pitts
- Re: [Bug-apl] Access to rational number numerator a... Juergen Sauermann
- Re: [Bug-apl] Access to rational number numerat... Frederick Pitts
- Re: [Bug-apl] Access to rational number num... Juergen Sauermann