float(%e^%e)



(Resending using plaintext mail for those who can't handle HTML mail.)

The fixes look good on their face, and solve the immediate problem,
but may cause other problems.  Indeed, until we know what float:t,
numer:t, float(), etc. are *supposed* to do, it is hard to say whether
they are correct.  The second fix in particular immediately causes
problems (see below).

To see what they currently do (which I'd hope has some vague
relationship to what they're supposed to do), I put together a little
test (below).  This test shows many peculiarities.  One of them is, I
believe, intentional (though perhaps questionable):

  -- Only numer:t and float:t go inside of an array subscript to
     evaluate numerically

But most of them appear to be bugs:

  -- numer:t evaluates %e^(3/2), but not %e
  -- numer:t is the only case which treats %e and %pi differently
  -- float:t doesn't evaluate sin(2), but does evaluate exp(3/2);
     float() does the opposite
  -- bfloat:t acts exactly like bfloat(), unlike float:t vs. float()
  -- float() and bfloat() don't agree in many cases
  -- numer:t evaluates one expt but not the other in 3^%e/2^%e
  -- why on earth does bfloat:t change fix to entier?
     etc.

But let's not throw out the baby with the bathwater.  The purpose of
all the complexity around %e is to prevent strictly symbolic
expressions from becoming gratuitously numerical; who wants to see
exp(%i*x) => 2.718^(%i*x)?  This currently never happens; neither does
x^3 => x^3.0 or 1/x => x^-1.0.  On the other hand, sin(%pi*x) does
gratuitously become sin(3.142*x), except in float().  Some functions
preserve 5^x and x^(1/3), others don't.  For real fun, try
flotest((-1)^float(1/3)) -- though part of that is really a different
issue....
 
             -S

--------------------------------------------------------------------------------

tests: [%E,%PI,2^(3/4),SIN(2),%E^(3/2),3^%E/2^%E,
        SIN(2)^%PI,a[FIX(SQRT(5))] ];

flotest(r) :=
       [EV(r, NUMER),
        EV(r, FLOAT),
        EV(r, FLOAT, NUMER),
        EV(r, BFLOAT),
        FLOAT(r),
        BFLOAT(r)];

fpprec:4;

apply(matrix,flotest(tests));

                                                              %E
                                 3/4                 3/2     3          %PI
               %E       %PI     2        SIN(2)    %E        ---     SIN   (2)   a
                                                              %E                  FIX(SQRT(5))
                                                             2

           [                                                     %E                               ]
numer      [   %E      3.142    1.682     0.91     4.482   0.15 3      0.74           a           ]
           [                                                                           2          ]
           [                                                                                      ]
           [                                                  %E                                  ]
           [                                                 3          %PI                       ]
float      [   %E       %PI     1.682    SIN(2)    4.482     ---     SIN   (2)        a           ]
           [                                                  %E                       2          ]
           [                                                 2                                    ]
           [                                                                                      ]
           [                                                     %E                               ]
float,     [   %E      3.142    1.682     0.91     4.482   0.15 3      0.74           a           ]
numer      [                                                                           2          ]
           [                                                                                      ]
bfloat     [ 2.718B0  3.142B0  1.682B0  9.093B-1  4.482B0  3.011B0   7.418B-1    a                ]
           [                                                                      ENTIER(SQRT(5)) ]
           [                                                                                      ]
           [                                                   %E                                 ]
           [                                         3/2    3.0           %PI                     ]
float()    [   %E       %PI     1.682     0.91     %E       -----     0.91       a                ]
           [                                                   %E                 FIX(SQRT(5))    ]
           [                                                2.0                                   ]
           [                                                                                      ]
bfloat()   [ 2.718B0  3.142B0  1.682B0  9.093B-1  4.482B0  3.011B0   7.418B-1    a                ]
           [                                                                      FIX(SQRT(5))    ]

PS As far as I can tell, there is no reasonable way to evaluate
 subscripts as bfloats; even scanmap does not go into subscripts.  But
 I doubt that cases like
 a[fix(10 * (100000000000000000000 * sqrt(2) - 141421356237309504880))]
 come up in real life very often....