typo?

Not this time.

In response to Kozuma3
Kozuma3 wrote:
GinjaNinja32 wrote:
16777216 + 1 = 1677216.

typo?

Nope. Try it and see!

edit: Example for you:
/world/New()
var/i = 16777200
while(i < 16777220)
world.log << num2text(i, 10)
i++
sleep(1)
Haven't got around to reading the content in full yet. It looks good though from what I have seen while doing some quick skimming.

Takes me back to not that long ago when I was completely bamboozled by the idea of binary and hexadecimal notation. I've since become comfortable with them, though I still feel I have yet to fully realize the power of this knowledge to the point that my programming sees growth. Maybe that'll change once I read this.

And yeah, there is a lot gold buried around here from Ter and others. I actually had a collection of bookmarks to a great amount of these, but unfortunately lost it all during an OS wipe on the assumption that Chrome would automatically preserve my account's bookmarks. (Turns out I had to save them manually.)
Here is the easy mode of binary, read this then re-read ters shit if you are having issue.

Say there is a wall, on the wall there are 6 light switches, and a number panel that looks like this: http://i.imgur.com/aiEG0To.jpg

Above each switch is a number, first one reads 1, the second reads 2, next reads 4, than 8, doubling from the last with each switch.

You flip the 1 switch on, the display reads 1. Simple enough.

You flip that off, the display reads 0

You flip the 2 switch on, the display reads 2.

you flip both of them on, what does the display read?

3! easy enough, it adds them!

You turn them all off and do 4 and 8, the number reads 12. Yep, It just adds the numbers you turned on.

"But Oh Great Stoner One", you say, "I think you smoked too much weed, this has nothing to do with binary numbers, it's just addition."

OH! But it IS binary numbers.

A switch in the on position is a 1, and a switch in the off position is a 0. Those switches were just a metaphor for a binary number. On that note, the first digit can be seen as as a 1 (in "normal" numbers), and every digit just doubles from the last.

Each of these digits or switches are called a bit, and 8 of them make up a byte, or rather, a number between 0 (all off) and 255 (all on) with the highest bit representing 128. (go on, do the math 1+2+4+8+16+32+64+128).

Congratulations, you can now convert binary numbers to normal decimal numbers in your head.

Now go re-read ter's post and see if it doesn't start making more sense.
@StonedOne thanks. Being succinct is far from being one of my strong suits.

I definitely need to clean this one up, because it's a rambling mess. Most of the information is solid, it's just the presentation of it that I'm lacking.
I enjoyed reading this, good information. One part that threw me off though is this.

Ter13 wrote:
XOR is like OR, but it's exclusive. In OR, it will only return true on a bit if only one of the two bits is on:

Is it OR, or XOR you're talking about?
In response to Kitsueki
That's XOR.
A       | 0 | 0 | 1 | 1
B | 0 | 1 | 0 | 1
--------|---|---|---|---
A OR B | 0 | 1 | 1 | 1
A XOR B | 0 | 1 | 1 | 0
One part that threw me off though is this.

Fixed. Thanks.

Looking back at this, I really regret doing everything with 3 bit examples rather than using Nybble sequences. At least Nybbles are a thing, but 3 bit groupings... Just aren't.
As one more example of what you could do with bitflags, you can actually implement a crafting system that stores item recipes as a number.

Since every number is a unique combination of bits, this is doable, ingredients are assigned a certain bit and you can save in associated list the recipes.

There's a few cons to this method but also a a few pros, depending on your needs this might be preferable to the common define ingredient list per recipe and loop over.

One con would be the fact two of the same ingredient have no meaning, that's probably the most major con but it could also be a pro if your system prefers that behavior.

The second con would be a limit on how many ingredients you can use as each requires a bit flag, you can have 16 ingredient types max.

I'm too lazy at the moment to write a code example but I'll throw this one in, if you want to count how many bits triggered on, this works:
proc/countBits(c)
. = c - ((c >> 1) & 0x5555)
. = (. & 0x3333) + ((. >> 2) & 0x3333)
. = ((. + (. >> 4) & 0x0F0F) * 0x0101) >> 8
In response to Rotem12
Rotem12 wrote:
limit on how many ingredients you can use as each requires a bit flag, you can have 15 ingredient types max.

16. You can use everything from 0x0001 (1) to 0x8000 (32768).
Ter13 wrote:
binary flags.
XOR:

XOR is like OR, but it's exclusive. In XOR, it will only return true on a bit if only one of the two bits is on:

1 ^ 1 is equal to 1 because more than one of the two bits is on.
You made a potentially confusing typo here should it not be equal to 0
Page: 1 2