Ambrus observed:
>  Phrases 8C. has this verb:
>     d0=: >:@<[EMAIL PROTECTED]  NB.  Length to represent y in base x
>  This verb is imprecise.  

This is a bug.  It may be related to (or the identical with) the one Raul
reported in 2006:

   
http://www.jsoftware.com/jwiki/System/Interpreter/Bugs06#head-253aeeae21360cdcfd8438613679821e0f3613f3

In any event, it causes the same symptom:

           10&#.b._1
        ($&10@>:@(10&(<[EMAIL PROTECTED]))@(1&>.)@(>./)@:|@, #: ]) :.(10&#.)

           10 #.^:_1: 999999999999
        0 9 9 9 9 9 9 9 9 9 9 9 9

(the inverse of  #.  should never produce leading zeros, as its definition
prohibits them.)

>  Could you tell me what the best way to do this calculation correctly is?

The fix for this problem is to have zero tolerance in the first place:

           d0m=: >:@(<.!.0)@^.

           10 d0m 999999999999
        12

           10 #.^:_1:!.0] 999999999999
        9 9 9 9 9 9 9 9 9 9 9 9

BTW, this leads to the insight that  d0  may be rewritten:

           10 #@:(#.^:_1:!.0) 999999999999
        12

Here's another (unrelated) bug:

           10 #.^:_1:!.0] 999999999999
        9 9 9 9 9 9 9 9 9 9 9 9

           10 #.^:_1 !.0] 999999999999
        |domain error
        |   10    #.^:_1!.0]1e12

I'm surprised the latter phrase is an error; I share the suspicion Henry
expressed here:

   http://www.jsoftware.com/pipermail/general/2007-November/031266.html
   
because I know there there are several undocumented places  !.  works (which
implies the interpreter uses the method Henry described), and because of
this message:

   http://www.jsoftware.com/pipermail/general/2004-August/017959.html

>  Also, how does one report bugs in the Phrases?

>From revision 5 (due to Henry) to revision 26 (due to Oleg), the Phrases
page on the Wiki (*) had this to say:  

       The J Phrases book contains a wealth of useful J idioms. It is no
longer 
        being maintained actively, and there is an ongoing project to move 
        phrases from the book to the appropriate subpages here.

I interpreted this to mean that the phrases shipped with J will no longer be
corrected (e.g., I believe some still use dotted names).  But since that
page has changed, I was perhaps mistaken.  If that's the case:

     http://www.jsoftware.com/jwiki/System/Library/Bugs

or this Forum is probably your best bet.

-Dan

*:                             Current: 
http://www.jsoftware.com/jwiki/Phrases
       "Unmaintained" introduced: 
http://www.jsoftware.com/jwiki/Phrases?action=recall&rev=5
                       then removed: 
http://www.jsoftware.com/jwiki/Phrases?action=recall&rev=26
-- 
View this message in context: 
http://www.nabble.com/Number-of-digits-in-a-number-tf4898850s24193.html#a14032393
Sent from the J Programming mailing list archive at Nabble.com.

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

Reply via email to