Postby **phlip** » Sat Feb 27, 2010 11:11 am UTC

Maybe a rule like... Take the representation at any point, cut off everything before that point, and move the decimal point (or whatever you call it in an arbitrary base) to just before the cutoff. So, for instance, you could take abcde.fghijk... and get 0.cdefghijk... or 0.ijk... or many other things. If the resulting number is >= 1, then the representation is bad. If the resulting number is <1 for all possible cutoffs, the representation is good.

So, for integer bases, this means no 0.999...-like representations, because 0.999... = 1.

For phinary, 0.11abcd... >= 0.10101010... = 1, so we don't use any representations that contain 11 or end 101010....

Equivalently, use the representation that comes last in lexical order (when they're prepended with 0s to the same length)... if you can increase the b^{n} place and decrease the b^{n-1} and lower places (without making them go negative), and still end up with the same number, then do so.

So 2 is 100_{√2} and not 10.01000001001..._{√2}, because the latter representation should "carry" upward.

This rule is a lot harder to judge for weird bases than it is for integers, though... would you know that 10.01000001001..._{√2} was a non-standard representation if it wasn't pointed out?

As a bonus, this also generalises the fact that all digits need to be in [imath]0 \le d < \left\lceil b \right\rceil[/imath]... you just have to say that the digits must be non-negative. Because if you try to have a digit d > b, then it'll be nonstandard, since 0.d > 1.

Code: Select all

`enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};`

void ┻━┻︵╰(ಠ_ಠ ⚠) {exit((int)⚠);}

[he/him/his]