A common design decision is how large to make a field.  For many numbers, we 
think that a byte will be large enough to hold practical values, but one day we 
will find out that it is not.  This is essentially the Y2k problem, or year 
2032 issue.

A simple variable integer coding (tied to byte ranges)

toVint =: [: ; (255&| ,~ 255 #~ <.@%&255) each

  toVint 566 44 
255 255 56 44

It now takes 3 bytes to store 566, and one byte to store 44.

the challenge is to write fromVint such that 

 
566 44 -: fromVint 255 255 56 44

as an extra challenge, is there a way to write toVint or fromVint such that it 
is faster than using intermediate boxing?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to