I'm working with a 32bit signed int, that should contain true/false flags for 24+ items, starting with an id of 1. So my first assumption was that each bit corresponds to its corresponding item item id. So to start off, I simply did
(flag_int >> item_id) & 1
And this worked - mostly. For example, starting with a flag int of 125831406, the expected result(left) compared to the actual result (right)
1 true true
2 true true
3 true true
4 false false
5 true true
6 true true
7 true true
8 false false
9 false false
10 false false
11 false true <<
.. ??? false
22 true false <<
23 ??? true
24 true true
25 true true
26 true true
The trouble is, not every flag ends up with known discrepancies, and when it does, it's not always on the same id, and the number of discrepancies always seems to vary between 1 and 2.
So this tells me there's some other value at play. The good news is that there's two possibilities that I know of. First, is the entry id - which in the example is 307, and second is an additional 0/1 flag, which in the example would be 1.
The bad news is, that I'm woefully deficient in bitwise operations when it comes to flags, and my attempts have been all for naught. So while I certainly don't expect the "right" answer, some ideas on what to try would be most appreciated.
The purpose of these flags was to determine whether or not certain parts of a character should be hidden, by the type of headwear they were wearing. Each ID identified a character type, and each item had two Flag IDs - one for each gender.
To avoid any extra variables - I elected to use the "Ears" flag - because unlike hair, or other parts, it should've been the easiest to spot, with the lowest chance of additional complexity. I mean, every character has ears, and only one style of ears - so it should've been pretty binary.
The discrepancies - despite how much time I spent making sure I was getting the most accurate results, were embarrassingly easy to explain - because it had nothing to do with the flags, and everything to do with the traits of these characters.
One character type of each gender would ignore their flag, because their ears were part of the base mesh, and couldn't be hidden.
two more character types- both genders, seemed to defy their flag, only because their ears weren't considered ears, so their display would be handled by a different flag.
So anyway, that was the problem. If I would've simply taken another look at the mesh of those character types, I would've saved myself a ton of time.
Related
I was wondering if lua "roblox", if statment has a way to go through....
well let me just show you.
local a = some.object.value
if a == 5 or a == 6 or a == 7 ................. goes on for a long time.
looking for a short cut. kinda like
if a <= 2000 then "some code" end
but this needs to start at like 5. Instead of 1
if a == 5 "through" 2000 then BLA end
Also i know i can use a for loop to do the trick but i was just wondering if there was a way to do it without for loop?
I have googled lua wiki and looked around but i could not find anything. :( It is probably do to i don't know what this type of thing would be called.
Just formulate your condition in English:
If your number is in the interval 5-2000, number is greater than or equal 5 and number is smaller than or equal 2000.
Now translate this to Lua
number >= 5 and number <=2000
If you're dealing with integer numbers only you may of course also use number > 4 and number < 2001
See Lua Reference Manual 3.4.4: Relational Operators and
Lua Reference Manual 3.4.5: Logical Operators
If the number is in the interval both conditions will be true. true and true is true.
If any of the conditions is false either because your number is smaller 5 or greater 2000 it evaluates to false as both false and true and true and false evaluate to false.
In an if statement:
if number >= 5 and number <= 2000 then
-- do something
end
I initially learned that if I want to see if a cell has any contents to use if(A1<>"",.... But as I receive more and more assistance on SO, it seems most people use if(LEN(A1),... Is there a difference? Did I learn the wrong information? Should I ever opt for one over the other or just always use LEN from now on?
pretty much the same result. difference is:
LEN(A1) - checks if A1 has a length
A1<>"" - checks if A1 is not equal to "empty"
then there is a length of the formula itself (some prefer to save 1 extra character space):
A1<>"" has 6 characters compared to LEN(A1) 7 characters
the superiority of LEN comes when you need to check for character count like:
=IF(LEN(A1)=4, TRUE, FALSE)
eg. output TRUE only if A1 value has exactly 4 characters
Stata does not replace a value, as I am commanding. What is happening?
I have this variable Shutouts, which is a float variable (%9.0g).
One observation has the value = 5.08; that is an error, it should be 5.
I type: replace Shutout= 5 if Shutout==5.08.
And, surprisingly to me, Stata responds:
replace Shutouts=5 if Shutouts==5.08
(0 real changes made)
I have a similar problem for a variable with the same characteristics, with the name Save_perc; one value is 9.2 but should be .92. And, also this time, I receive this response from Stata:
replace Save_perc=.92 if Save_perc==9.2
(0 real changes made)
Why "0 real changes"?
It seems like a very banal problem, but I have been working on it for like 30' and I cannot really figure it out.
it has to do with how floating numbers are stored into memory. You should not use == when comparing two different number formats because some internal storage approximation can make the comparison fail.
In your case, you should just use
Shutouts=5 if Shutouts > 5.07
or
Shutouts=5 if Shutouts == float(5.07)
I can't find an example close enough to this one on StackOverflow so here goes:
I want to return a message "Type?" if cell X is blank and cell Y has any text. But I'm trying to nestle it into an existing set of IFs.
Existing :
=IF($G241="Evo";M241*L241;IF($G241="Free";M241*L241;IF($G241="GN";M241*L241))))
Nestling this into the above:
=IF(AND(NOT(ISBLANK($J234));ISBLANK(G234));"Type?";"OK")
I tried this but it returns FALSE, maybe due to the AND I'm using, which I need since I'm creating a return based on two cells two cells.
=IF($G240="Evo";M240*L240;IF(AND(NOT(ISBLANK($J240));ISBLANK(G240);"Type?";"OK");IF($G240="Free";M240*L240;IF($G240="GN";M240*L240))))
getting Error:
AND expects boolean values. But 'Type?' is a text and cannot be coerced to a boolean.
IF(and(isblank(cell x),iferror(isstring(cell y),false)),"Type?","OK")
That should do it for you I think. you will need to replace cell x and cell y with the appropriate references. The iferror statement is there to catch what happens when evaluating a blank cell y.
The problem with this formula
=IF($G240="Evo";M240*L240;IF(AND(NOT(ISBLANK($J240));ISBLANK(G240);"Type?";"OK");IF($G240="Free";M240*L240;IF($G240="GN";M240*L240))))
is you are trying to check G240 for different values when it cant. Lets simplify your formula. We will replace your empty cell check with FORMULA 1
=If($G240="EVO", Do True Condition, Do Formula 1, IF(G$240=Free, Do Free True Condition, Do Free False Condition)
The problem is since you already did something (Formula 1) when G240 = "EVO", you cant start another check on what G240 after the fact with the way you have embedded your formula. a batter way of thinking of it is how to do a second check when G240="EVO" is false. Remember the general format of an if statement is:
IF(CONDITION,True Result, False Result)
There are only 3 things that go into an if statement. you tried putting in 3.
Try rearranging to this:
=If($G240="EVO", Do True Condition, IF(SOME CHECK to determine DO FOMULA 1 or CHECK for G240 = FREE, Do Formula 1, IF(G$240=Free, Do Free True Condition, Do Free False Condition)))
Basically break down what you want to check for in G240 and do it in sequence with your IF statement. Right now with what you have written, I cant tell how you want to determine if you want to run your formula 1 or if you want to check if G240="free" since you have two different outcomes if G240="Free"/
OK I think i found the issue. The IF(AND(NOT(ISBLANK works on it's own since there are no other IFs in the formula. I do want to test two different cells for text(letters) in order to show a warning if one cell was blank while the other not. But as soon as you insert the (AND into a string of multiple IFs it doesn't work.
Simply removing the (AND was all I needed to do. Another way to achieve a test for more than one blank cell was to simply add multiple IF(ISBLANKs.
EG: =IF(ISBLANK(A1)+IF(ISBLANK(A2)>2;condition true;condition false)
ForwardEd thanks very much for your help!
Regards
I have a piece of code in front of me that iterates through a long list of urls and something is going wrong when those urls include a certain type of document. I don't want to see every iteration, so I've set up a conditional breakpoint.
The trouble is that I'm not a C++ programmer so I'm slightly having to fish around to work out how to do what I want and I may be doing something obviously wrong.
My current condition is thus:
(strstr( url, "xlsx") == 0x00000000)
This should mean every time the url ( which is a UNICODE_char* ) doesn't contain the literal "xlsx" strstr will return a null pointer which should match the condition, as I understand it. I actually want it the other way round in the long term, but as there are only a couple of "xlsx" urls and I want to check it is working I have it this way up for now.
Well, my condition is not being met or at least the breakpoint is not being triggered.
Assuming that I was doing something wrong I copied the same value as a watch expression and set an unconditional breakpoint on the line before. The result looks like this as I step past my coinditional breakpoint:
Name | Value
================================================
(strstr( url, "xlsx") == 0x00000000) | true
So apparently my condition can be true as far as the watch window is concerned but not trigger the conditional breakpoint.
In order to experiment further I tried flipping the condition over so it was
(strstr( url, "xlsx") != 0x00000000)
As far as the conditional breakpoint is concerned this is also false, which seems a bit funny as that would mean it neither equalled nor didn't equal the null pointer value.
Is this some unusual property of null values in C++? Is there something really obvious I'm missing or some quirk of the language that is causing me to totally miss the boat on this one?
If your url is a unicode string, have you tried using wcsstr?