Re: [amibroker] Finding all possible combinations of numbers to reach a given sum

 

Greetings --

Lets assume we have sum total of 21 for the flags that are active, how do I programmatically find the three flags that are on are positioned on 0, 1 and 4.

-------------------------------------

Almost.

The properties that are set for a composite flag value of 21 are 4, 2, and 0.  2^4 == 16 + 2^2 == 4 + 2^0 == 1

Properties 4, 1, and 0 True result in a composite flag value of 2^4 + 2^1 + 2^0.  16 + 2 + 1 == 19.

Best,
Howard

On Wed, Feb 17, 2016 at 10:21 AM, l3456@excite.com [amibroker] <amibroker@yahoogroups.com> wrote:
 

Thanks so much for the explanation. you said
"So, to decode a flag, check to see which powers of 2 are present in the number."
How is this done? What is the logic?I need to code this in afl. Lets assume we have sum total of 21 for the flags that are active, how do I programmatically find the three flags that are on are positioned on 0, 1 and 4.

__._,_.___

Posted by: Howard B <howardbandy@gmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (10)
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___

Related Posts


EmoticonEmoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng
:lv