I think the implementation is correct, though it lets you use numbers larger than the specified base, and always returns an integer in base 10: 4b5 NB. 5 > 4 but no problem 5 4bz 35 This is the same behaviour as #. : 4 #. 5 5 4 #. 1 1 5
when using base specification using b, J lets you specify 0-35 by 0 to 9 and 'a' to 'z'. You can use bases as large as you want, but you won't be able to write any of the numbers digits larger than 35. The digits do retain the right relation with each other though. 100b32z 30236 100b32z = (3 * 100^2) + (2*100^1) + (35*100^0) 1 100b32z = 100 #. 3 2 35 Summarizing, one could implement similar functionality as based integers as follows (taking a string): base =: #. '0123456789abcdefghijklmnopqrstuvwxyz'&i. 1bhello ([,=) 1 base 'hello' 97 1 10bhello ([,=) 10 base 'hello' 186334 1 Re-reading your email, I think you might be confusing the base notation for specifying an integer in base n (e.g. 16b123abc, returns an integer which would be represented by hexadecimal digits 123abc) and converting to base-x (which would be done by x #: or x #.inv, the latter of which automatically gives you an appropriate amount of replications of x) : 4 4 #: 5 1 1 4 #. inv 5 1 1 #: does not automatically replicate its left argument since J allows you to specify a variable base, e.g. for converting seconds to days hours minutes seconds: 0 24 60 60 #: 100000 NB. how many d,h,m,s is 1e5 secs ? 1 3 46 40 I hope this sheds some light on your doubts. On Tue, 7 Jun 2022, 16:25 yt, <yves.tan...@frmail.net> wrote: > > Dear All, > to start in J, i use labs. > > in this page, > ── (23 of 35) Numbers (ctd) ───────────────────────────────── > Note the "e" notation used in 2.41785e24, meaning: > > 2.41785 * 10^24 > > J has other number notations that use letters: > ) > 3b102 NB. base (102 in base 3) > 11 > > my eyes are horrified by the result > > 11 in base 3 is > (1*3^1)+(1*3^0) > 4 > > i verifid list of power > 3^i.5 > 1 3 9 27 81 > > i tried by hand to convert 102 in base 3 > (1*3^4)+(2*3^2)+(3*3^0) > 102 > result is 1 0 2 0 and not 11 lik your sample > > not only > 99b102 102 in base 99 > result by hand is (1*99^1)+(3*99^0) > but J give a strange result > 99b102 > 9803 > > and the golden medal for the big foot of calculus > 4b5 > 5 > (1*4^1)+(1*4^0) > 5 > the number 5 in base 4 is 11 ! > not only ! 5 is over the base 4 > > possible i do a mistake, i dont masterize J language. > > i try to use a best notation > +/ 0 0 1 1 * 4^|. i.4 > 5 > 0 0 1 1 in base 2 result 3 in base 10 > last try : > 2b3 > 3 > > Best Regards, > Yves > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm