Hmm.. The notation 0.141592653 gives you an intermediate result using the IEEE754 standard (specifically the 64 bit binary version of that standard).
This means that you have 53 bits of precision in that representation. So maybe something like this would serve your needs: binfrac=:3 :0 assert. 1>y assert. 0<y exp=. <.-2^.y (exp#0),#:<.0.5+(2^53+exp)*y ) NB. beware email induced line wrap in the result binfrac 0.14159265 0 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 0 0 1 0 0 0 Of course, this discards the heuristic that 2 x: uses, but that heuristic was the root of your distress in this context. Still, this exposes a part of an issue distinguishing binary and decimal fractions, which is that multiples of 5^_1 cannot be represented exactly using binary fractions: binfrac 0.2 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 Still... I hope this helps, -- Raul On Wed, Aug 4, 2021 at 7:00 AM R.E. Boss <[email protected]> wrote: > > Now > #: 0.14159265 > 0.14159265 > > I would like to have #: working for fractions as well (low chances for such a > change request?), so > #: 0.14159265 > 0 0 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 0 0 0 1 1 0 > 1 0 1 0 0 1 1 1 1 0 0 0 0 1 > since > #:2 x: x: 0.14159265 > 0 0 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 0 0 0 1 1 0 > 1 0 1 0 0 1 1 1 1 0 0 0 0 1 > 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > And so > 0.14159265= 0.00010010000111111011010100111100100011010100111100001 > > But with one digit more I'm in trouble > #:2 x: x: 0.141592653 > 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 0 1 1 0 0 0 0 1 1 1 1 0 1 1 0 1 1 > 1 1 1 0 1 > 1 0 0 0 1 1 0 1 0 0 1 1 1 1 0 1 1 1 0 0 1 0 1 1 0 0 0 0 1 0 0 0 1 1 0 1 0 0 1 > 1 1 1 1 0 > > Anyone with a smart way out? > > TIA. > > R.E. Boss > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
