I don't think rounding is desirable, here.

Instead, what is desired is a mechanism analogous to the display
precision where the precision of the collection is based on its
largest members.

But all that's needed here, is a loss of a few unnecessary bits of
precision.  So what we do is add a number (which drops a few bits of
precision) and then subtract it again.

FYI,

-- 
Raul


On Wed, May 2, 2012 at 11:31 AM, Edward Mokurai Cherlin
<moku...@sugarlabs.org> wrote:
> On Wed, May 2, 2012 6:11 am, Bo Jacoby wrote:
>> Hello J'ers
>>
>> Even if a complex number is actually real it may display nonzero imaginary
>> part because of round-off errors. Adding and subtracting 1e6j1e6 removes
>> the round-off error, but is there a better or more general solution?
>
> J uses the APL definition of complex floor, so normal rounding works.
>
>   <.1j0.00000001+0.5
> 1
>   _1+<.1j0.00000001+0.5
> 0
>
> --
> Edward Mokurai (默雷/निशब्दगर्ज/نشبدگرج) Cherlin
> Silent Thunder is my name, and Children are my nation.
> The Cosmos is my dwelling place, the Truth my destination.
> http://wiki.sugarlabs.org/go/Replacing_Textbooks
>
>
> --
> Edward Mokurai (默雷/निशब्दगर्ज/نشبدگرج) Cherlin
> Silent Thunder is my name, and Children are my nation.
> The Cosmos is my dwelling place, the Truth my destination.
> http://wiki.sugarlabs.org/go/Replacing_Textbooks
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to