Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2008

Tip: Looking for answers? Try searching our database.

Trinary Generator?

Thread view: 
TheBigPJ - 29 Feb 2008 16:32 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.