<. {. +. 3j4
3
   3!:0 <. {. +. 3j4
4


----- Original Message ----- 
From: "Sashikanth Chandrasekaran" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, April 28, 2006 6:05 PM
Subject: [Jprogramming] simple question on integer->complex->integer conversion

Using version 504.

I have an integer noun that I transform (temporarily)
to a complex number. When I try to re-convert it, the
best I am able to do is make it a floating point. Any
suggestions on how to (quickly) make it an integer
again? Thx, -sashi.

   (] ; 3!:0 ; [: # 3!:1) zz =. 7
+-+-+--+
|7|4|20|
+-+-+--+

   NB. temporarily make it complex
   (] ; 3!:0 ; [: # 3!:1) zz =. j.&1 zz
+---+--+--+
|7j1|16|32|
+---+--+--+

   NB. throw away the imaginary part, still complex :(
   (] ; 3!:0 ; [: # 3!:1) zz1 =. -&(0j1) zz
+-+--+--+
|7|16|32|
+-+--+--+

   NB. Try to make it atleast a floating point. 
   (] ; 3!:0 ; [: # 3!:1) zz2 =. | -&(0j1) zz
+-+-+--+
|7|8|24|
+-+-+--+

   NB. doesnt make a difference if it is in-place
   (] ; 3!:0 ; [: # 3!:1) zz =. | -&(0j1) zz
+-+-+--+
|7|8|24|
+-+-+--+

   NB. try some conversions...
   (] ; 3!:0 ; [: # 3!:1) zz =. ([: 3!:2 (3!:1)) zz
+-+-+--+
|7|8|24|
+-+-+--+

   NB. ask for help before messing with 3!:1 and 3!:3

PS: I checked out 3!:5 in the online vocabulary, but
there are no operands that seem to help. 


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to