[q-lang-users] Exponentiation operator
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-06-16 18:22:20
|
The built-in ^ operator currently returns a floating point value in all cases. That makes sense, because it is supposed to work with negative and fractional exponents too, so this seems to be the only way to make ^ work consistently. For the case of integer bases and positive integer exponent there's the pow function which returns an Int value. Now I'm reconsidering this. Maybe it would be better if ^ actually returned an Int where this is possible, and a Float otherwise? (This wouldn't be possible in a language with static typing like Haskell, of course, but Q doesn't have this problem.) A similar issue arises with the definition of ^ for Rational. Should Rational ^ Int be a Rational? Or a Float, like Rational ^ Rational and Rational ^ Float are? Comments appreciated. :) Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |