|
|||
|
All,
A co-worker of mine is working on a program using a financial model that has some binary tree type logic (sorry - don't know much more about than that) where she will know how many "levels" she has - say 3 - and then needs to generate all binary numbers from 000 to 111 - and the process will do some calculations for each one. She was originally trying a multistage loop where she set the first digit, then looped through 0 and 1 to set the 2nd, etc. but it was very inefficient plus gets more and more complicated the greater the number of "levels" the tree will branch too. My idea was just loop through all the base 10 numbers that are represented for the number of "levels" being used - say if 3 digit binary you know you need to go from 0 to 7 (i.e. 0 to (2^n)-1 ) - and then within that one loop use the binary3. format (or binaryN) on the loop value to get the binary representation of that number. Is there any simpler way to do this that we are missing? Thanks, Jennifer R. Holdcraft System Analyst, Market Risk Analytics American Electric Power 614-583-6761, Audinet 220-6761 Cell: 614-307-4258 jrholdcraft@aep.com |
|
|
||||
|
||||
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: binary number loop - i.e. going through all binary | Chang Chung | Newsgroup comp.soft-sys.sas | 0 | 07-21-2008 08:09 PM |
| Re: binary number loop - i.e. going through all binary | data _null_, | Newsgroup comp.soft-sys.sas | 0 | 07-21-2008 07:32 PM |
| Re: Basic do loop question | toby dunn | Newsgroup comp.soft-sys.sas | 0 | 11-22-2006 03:11 PM |
| Re: Basic do loop question | Ian Whitlock | Newsgroup comp.soft-sys.sas | 0 | 11-22-2006 03:00 PM |
| Re: gettting out of the nested loop | Terjeson, Mark | Newsgroup comp.soft-sys.sas | 0 | 07-19-2005 04:22 PM |