OK, I was given a formula to determine a float value between 0.0 and 1.0 using i and j (coordinates of a value in a 2D array). I simply want to know exactly what this formula does. It makes no sense to me. I have implemented it in its own function where the int values of i and j are passed as parameters. Can someone provide an explanation? I don't HAVE to understand it, as he gave it to us just to use as is, but I really want to know.
float col = float (((i & 0x08) == 0) ^ ((j & 0x08) == 0));
What exactly is going on here?
To calculate total float, subtract the task's earliest finish (EF) date from its latest finish (LF) date. It looks like this: LF - EF = total float. Alternately, you can subtract the task's earliest start (ES) date from its latest start (LS) date, like this: LS - ES = total float.
Float, sometimes called Slack (float) , is the amount of time an activity, network path, or project can be delayed from the early start without changing the completion date of the project. Total float is the difference between the finish date of the last activity on the critical path and the project completion date.
Total Float Calculation A project's total float is the difference between the finish date of the last task on the critical path and the project completion date. This will tell you how much total time the critical tasks can be delayed before the entire project misses its completion target.
Free float is measured by subtracting the early finish (EF) of the activity from the early start (ES) of the successor activity.
The result, if plotted with i,j
as the x,y coordinates, will be a checkerboard with squares of 8x8 pixels.
The i & 0x08
and j & 0x08
are just testing a single bit of each axis. That bit will change state every 8 pixels.
The == 0
will convert each result to a boolean, which evaluates to either a 0 or 1. It also inverts the result, but I don't think that's relevant in the overall formula.
The ^
exclusive-or operator will return 0 if the two are the same, or 1 if they're different. That's how you get the checkerboard - the result alternates each time either i
or j
crosses a boundary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With