kawa numerics unstable
Per Bothner
per@bothner.com
Fri Nov 13 01:24:00 GMT 2009
On 11/12/2009 04:28 PM, thomas kirk wrote:
> thanks for the clarification. it's not a problem, was just
> taken by surprise in places where i had assumed equalness
> (i apparently need to watch the changelogs more closely).
> the advantages you describe are worth the minor code
> adaptations.
One problem (bug) is that some Kawa functions are defined
to return int rather than integer, which means they can
unexpectedly overflow, even in "portable" Scheme code:
$ kawa
#|kawa:1|# (* 1000000000 (string-length "abcdefghijk"))
-1884901888
#|kawa:2|#
Ouch.
There are possible fixes, of course. The obvious one
to change string-length's return type to integer, but
that is expensive. A better solution is to change
string-length to return a "kawa-int" (or something like
that), which is implemented as a 32-bit unboxed int,
but is treated as forcing unlimited-precision
arithmetic, depending on context and the other operand(s).
That would be a bit hackish and possibly confusing, but
should be doable. Not a priority right now, though.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
More information about the Kawa
mailing list