I think you understand correctly, John. The number of bits needed to store a value x is iceil(log2(x)), so you could plug the maximum value you expect this type to "hold" but that doesn't tell you everything you need to know; you still need to add another bit if you want negative numbers, etc...
To map this to actual types, you would have to build a function that returns types from the number of bits required. Of course, the parser already does this somewhere: julia> typeof(1000000000000000000) Int64 julia> typeof(10000000000000000000) Int128 So I'm guessing there's some kind of logic in the flisp somewhere that inspects literals and calculates the type. I don't know where that is, though. -E On Sun, Dec 29, 2013 at 7:00 PM, John Myles White <[email protected]>wrote: > I’m a little unsure what you mean. Are you asking for a function that > given a 32bit value returns that it’s of type Uint32? I would guess (but > maybe am way offbase) that you’ll be storing 30bit unsigned integers inside > of Uint32’s, right? > > — John > > On Dec 29, 2013, at 7:45 PM, andrew cooke <[email protected]> wrote: > > > question says it all really. if i need to deal with 30bit unsigned > integers, is there anything that returns Uint32? > > > > [obviously i can just tabulate what there is if missing, but i wondered > if it would also be good for the std lib.] > > > > thanks, andrew > >
