[Jprogramming] When a <. _ is less than a
Raul Miller
rauldmiller at gmail.com
Thu Feb 4 00:30:22 UTC 2016
On Wed, Feb 3, 2016 at 5:19 PM, Marshall Lochbaum <mwlochbaum at gmail.com> wrote:
> I sent an email about the problem of coercion to integer a month ago; my
> recommendation was fl:
>
> MAX =: ->: MIN =: _2 <.@^ 63
> fl =: ((MAX*-.@]) + [: <. MIN>.*) <:&MAX
Note that this won't work right on 32 bit J. The values for MAX and
MIN would be wrong. Nor would it do the right thing on a 128 bit J
(for example, if anyone ever cares to implement something like that
for IBM 370). That said, my earlier MAXINT and MININT don't work right
on 32 bit J, either. So here's fixed (and slightly simpler) version of
those definitions:
MININT=: _1-MAXINT=: +/".":x:}:+:^:(4>:3!:0)^:a:1
These are the same values as your MAX and MIN on 64 bit J, but these
definitions also work on 32 bit J, and hypothetically speaking would
also work for a 128 bit J.
That said, there's also a problem with your fl, on current 64 bit J,
which is related to what you were posting about earlier:
3!:0 fl MAX-432.1
8
3!:0 fl fl fl MAX-432.1
8
Here, a positive floating point value which is smaller than MAX does
not get converted to integer.
--
Raul
More information about the Programming
mailing list