Addition of Squares for Calculation Topic is solved

Discuss Autohotkey related topics here. Not a place to share code.
Forum rules
Discuss Autohotkey related topics here. Not a place to share code.
AngryPig
Posts: 3
Joined: 23 Mar 2018, 12:15

Addition of Squares for Calculation

19 Jul 2022, 17:13

In the GUI Control Types documentation, you can use the sum of multiple numbers to determine a specific outcome. So 1 + 4 + 16 will add up to a unique number and that is a specific combination of instructions. Is there a name for this sort of process for instructions?
iseahound
Posts: 1451
Joined: 13 Aug 2016, 21:04
Contact:

Re: Addition of Squares for Calculation  Topic is solved

19 Jul 2022, 20:55

Yes, it's setting bits in a flag.

For example if setting text styles:
  • bold = 1
  • italic = 10
  • underline = 100
I could combine the individual options into one value, by placing them positionally in a binary number.

So 0b100 is underline, 0b110 is underline and italic, and 0b111 is all three options.
https://www.autohotkey.com/docs/commands/GuiControls.htm wrote: 1: Prevent unmodified keys
2: Prevent Shift-only keys
4: Prevent Ctrl-only keys
8: Prevent Alt-only keys
16: Prevent Shift+Ctrl keys
32: Prevent Shift+Alt keys
64: This value is not supported (it will not behave correctly)
128: Prevent Shift+Ctrl+Alt keys
in binary those numbers are:
0b1 (1)
0b10 (2)
0b100 (4)
0b1000 (8)
0b10000 (16)
0b100000 (32)

https://oeis.org/A000079 Sequence - Powers of 2

The reason binary representation is used is because each position or digit (On / Off) represents a composable option. E.g. I can combine any of the options listed from 1-128 which provides a range of numbers from 0-255.
AngryPig
Posts: 3
Joined: 23 Mar 2018, 12:15

Re: Addition of Squares for Calculation

22 Jul 2022, 02:57

iseahound wrote:
19 Jul 2022, 20:55
Yes, it's setting bits in a flag.
Cheers for the in-depth answer and article, looks like I have some reading to do!

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 15 guests