I need to generate all possible combinations of 16 bit long trinary.
e.g.
0000000000000000
0000000000000001
0000000000000002
0000000000000010
0000000000000011
0000000000000012
0000000000000020
Anyone know of a good generator I could get my hands on quickly?
Thanks,
Peter
Eric Sosman - 29 Feb 2008 17:16 GMT
> I need to generate all possible combinations of 16 bit long trinary.
> e.g.
[quoted text clipped - 7 lines]
>
> Anyone know of a good generator I could get my hands on quickly?
You mean "trit," not "bit," and the usual word is "ternary."
Here's your generator:
for (int i = 0; i < 43046721; ++i) {
... do whatever you want with `i' ...
}
NOTE: This is for educational purposes only. If you use my
sophisticated ternary generator in a commercial product or
in furtherance of any commercial venture, you must first
negotiate a license with me. It's not expensive, though,
since I charge on a sliding scale: just one cent for the
first ternary number, three for the next, nine for the third,
and so on.

Signature
Eric.Sosman@sun.com
TheBigPJ - 29 Feb 2008 17:45 GMT
lol.
Hmmmm.... looks like i goes through 3^16 time to me :)
I was wondering if there was an easy function in Java to turn it into
ternary?
Peter,
Eric Sosman - 29 Feb 2008 18:40 GMT
> lol.
>
> Hmmmm.... looks like i goes through 3^16 time to me :)
>
> I was wondering if there was an easy function in Java to turn it into
> ternary?
Response #1: What do you mean by "turn it into ternary?"
Response #2: Integer.toString(value, 3)
Response #3: Have you ever heard of the % operator?

Signature
Eric.Sosman@sun.com
TheBigPJ - 01 Mar 2008 00:17 GMT
Thanks for your help. I managed to produce all combinations of 16 bits
in ternary :)
Peter,
Roedy Green - 01 Mar 2008 02:19 GMT
On Fri, 29 Feb 2008 08:32:06 -0800 (PST), TheBigPJ
<TheBigPJ@gmail.com> wrote, quoted or indirectly quoted someone who
said :
>I need to generate all possible combinations of 16 bit long trinary.
see http://mindprod.com/jgloss/comination.html
http://mindprod.com/jgloss/radix.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com