David Ward Lambert wrote:
> I'd like to convert rational to float. What, please, is a better way?
> 1.001 * 2r5 NB. unsatisfying.
Since x: 2%5 converts 0.4 to 2r5 we might expect that (x:^:_1) 2r5
would convert 2r5 to 0.4 :
(x:^:_1) 2r5
0.4
and indeed it does. Moreover, since we know the dyad x: accepts a range
of "function codes" as right arguments, which apply useful transformations
to its left argument, we might suspect it provides one for this kind of
transformation. For mnemonic reasons, we might even expect this function
code to be _1 (to invoke the concept of inversion):
_1 x: 2r5
0.4
and indeed it is. Of course, this latter was just a suspicion; we could've
canonically confirmed it by reading the definition of the dyad x: :
http://www.jsoftware.com/help/dictionary/dxco.htm
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm