IFF Statement - Informatica powerCenter - powerbi

I've seen an IFF that I have to translate to Java, but I'm not sure what it does.
Is similar to:
IFF(cod=199, mot <> 'A', null);
I have a table of records, in which they are going to pass a filter, one column is cod and another is mot.
The IFF is in a filter, if a cod is different from 199, is that record deleted because there is a null in the "else"?
In another language would it be equal to:?
if (code == 199) {
return mot != 'A'
} else {
return false??; or return null?
}

Since IIF is in a filter, null condition is always false and will exclude the data from going ahead and excluded from that point.
And you can combine both condition into one -
if (code == 199 and mot != 'A') then true else false.
So, equivalent code can be -
if (code == 199 and mot != 'A') {
return true
} else {
return false}

Related

Pinescript - Simple if else

I am currently trying to get back into coding (its been some time) and for some reason I cant get my pinescipt to execute properly.
The intent is that
Condition for strategy execution is met, on the first candle a particular strategy.entry with alert_message is executed (3commas deal start).
On the next candle, or any subsequent candle WHILE the deal is open, if the same condition is met a second strategy.entry and alert_message is executed (3commas deal add funds)
If following these the event is NOT met, strategy close is triggered.
At the moment, for some reason its only triggering the deal start repeatedly, and not jumping to the add - I know its a dumb mistake - I just cant see it!!!
base_Long_Order_Placed = 0
message_long_entry = "3commas deal start"
message_long_addition = "3commas deal add funds"
message_long_exit = "3commas close all deals"
longCondition = SECRET_SAUCE
if (longCondition == true and base_Long_Order_Placed == 0)
strategy.entry('Long', strategy.long, when = longCondition ==true and barstate.isconfirmed, alert_message = message_long_entry) /
base_Long_Order_Placed := 1
else if (longCondition == true and base_Long_Order_Placed == 1)
strategy.entry('Long', strategy.long, when = base_Long_Order_Placed == 1 and longCondition ==true and barstate.isconfirmed, alert_message = message_long_addition)
else if (longCondition == false)
strategy.close('Long', when=longCondition == false and barstate.isconfirmed, alert_message = message_long_exit)
base_Long_Order_Placed := 0
else
na
Your script will be executed on every bar. When you define a variable like below
base_Long_Order_Placed = 0
It will be re-defined every time and base_Long_Order_Placed == 0 will always be true. If you want to keep its value between executions, you need to use the var keyword.
var base_Long_Order_Placed = 0
Edit
var is just a keyword that tells the compiler to keep its value for the next execution. It is just a regular variable otherwise. It will keep its value unless you overwrite. It will not iterate unless you do
base_Long_Order_Placed := base_Long_Order_Placed + 1
So, you can definitely reset it when your condition is met.
if (deal_closed)
base_Long_Order_Placed := 0

How does "if" work with registers in verilog?

a = reg[3:0].
what values of "a" return true in: "if(a)"?.
which cell of the register a does the "if" check in the previous format?.
Does it return 0 only for a=0000 or are there other values for a that make if(a)=0?.
If a is reg [3:0], it evaluates to false inside if statement only when a == 4'b0000.

What is the difference between this two condition?

What is the difference between this two conditions?. I tried to use both conditions but different output.
if(!(data1 == true || data2 == true))
{
// do something
}
And
if(data1 != true || data2 != true)
{
// do something
}
!(data1 == true || data2 == true) this condition is same as data1 != true && data2 != true
Using ! operator with == gives != and using ! operator with || will give &&.
Your 2nd condition data1 != true || data2 != true will be same as your 1 st condition If you replace || with && in 2nd condition
!(data1 == true || data2 == true)
This is equivalent of (see also De Morgan's laws):
(data1 != true && data2 != true)
Which is obviously different from
(data1 != true || data2 != true)
fist condition :
if(!(data1 == true || data2 == true))
{
// do something
}
It will false the evaluated result if the result is true and if the result is false then the result will be true.
If data1 == true is true it will not check data2 condition and make all condition false. so if data1 == true then whole condition is false. Same as data1. And if data1 or data2 is false (one is false) then the code will be executed.
Second Condition
if(data1 != true || data2 != true)
{
// do something
}
It will do the reverse of the first condition. First it will check that if data1 is not equal to true, so if data1 is false then the code will be executed.

C++ operators precedence

I am using this statement
if ((pm && pn) || (pm == false && pn == false))
it is supposed to return true only if both pm and pn are true or if both are false. But this is also returning true if only only first one (pm) is true.
So now it is acting like this:
0 0 = 1
0 1 = 0
1 0 = 1
1 1 = 1
but I need it to work like this:
0 0 = 1
0 1 = 0
1 0 = 0
1 1 = 1
can you tell me where am I making mistake?
What you want is simply:
if (pm == pn)
You are checking if pm is true twice. You also need to check if both are the same, not whether they are both true. So,
if ((pm == pn)
^^ ^^
pm && pm
should be
pm && pn
^
The whole expression can be simplified to
pm == pn
if the variables already have bool type.
Why not try xor?
if (!(pm ^ pn)) { /*...*/ }
Or simply equal?
if (pm == pn) { /*...*/ }
if ((pm && pm) || (pm == false && pn == false))
it is supposed to return true only if both pm and pn are true or if both are false. But this is also returning true if only only first one (pm) is true.
Because you made a typo. You meant pm && pn.
Instead just write if (pm == pn), which is equivalent along as the only semantic values are indeed true and false for both variables.
Plus, consider making your variable names clearer and more distinct.
Note that operator precedence has nothing to do with this.
Since the question's title asks about precedence, note that || has lower precedence than &&. So the two sets of inner parentheses are redundant, and the original expression is just a longer way of saying
if (pm && pm || pm == false && pn == false)
Now, fixing the obvious typo:
if (pm && pn || pm == false && pn == false)
Removing the unneeded explicit comparisons:
if (pm && pn || !pm && !pn)
And, finally, a less obvious transformation, which others have suggested:
if (pm == pn)

C++ Ternary operator logic

I'm having trouble figuring out what this if statement is doing. This is not my code so I am simply trying to understand what the Ternary operator is doing.
if((model[STRIDE].isLogging == true ? model[STRIDE].value : g_uiStride) == g_uiStride &&
(model[NUMVERTS].isLogging == true ? model[NUMVERTS].value : NumVertices) == NumVertices &&
(model[PRIMCOUNT].isLogging == true ? model[PRIMCOUNT].value : primCount) == primCount &&
(model[STARTINDEX].isLogging == true ? model[STARTINDEX].value : startIndex) == startIndex)
{
First,
(model[STRIDE].isLogging == true ? model[STRIDE].value : g_uiStride) == g_uiStride
could be written:
(model[STRIDE].isLogging ? model[STRIDE].value : g_uiStride) == g_uiStride
the ternary
model[STRIDE].isLogging ? model[STRIDE].value : g_uiStride
checks to see if model[STRIDE].isLogging is true. If it is, it takes the value model[STRIDE].value. If not, it takes the value g_uiStride. This is then compared to g_uiStride.
So, if it isn't logging, then this portion is automatically true because g_uiStride is compared to itself. If it is logging, it is true if mode[STRIDE].value == g_uiStride
and
#1.
if (model[STRIDE].isLogging is true then
RESULT1 = (model[STRIDE].value == g_uiStride) else
RESULT1 = (g_uiStride == g_uiStride)
)
#2.
if (model[NUMVERTS].isLogging is true then
RESULT2 = (model[NUMVERTS].value == NumVertices) else
RESULT2 = (mVertices == NumVertices)
)
#3.
if (model[PRIMCOUNT].isLogging is true then
RESULT3 = (model[PRIMCOUNT].value == primCount) else
RESULT3 = (primCount == primCount)
}
#4.
if (model[STARTINDEX].isLogging is true then
RESULT4 = (model[STARTINDEX].value == startIndex) else
RESULT4 = (startIndex == startIndex)
)
if (RESULT1 && RESULT2 && RESULT3 && RESULT4) {
/* yay */
} else {
/* damn */
}
In general the ternary conditional operator uses a condition to choose between two alternatives:
condition ? first_alternative : second_alternative
In this case it is very unnecessarily complicated by comparing to true and one object to itself
if((model[STRIDE].isLogging == true ? model[STRIDE].value : g_uiStride) == g_uiStride
This can be reduced to
if((model[STRIDE].isLogging ? model[STRIDE].value : g_uiStride) == g_uiStride
which is also equivalent to
if (model[STRIDE].value == g_uiStride || !model[STRIDE].isLogging
telling us that either value is equal to some global value, or we don't care because we are not logging anyway.
blah = (model[STRIDE].isLogging == true ? model[STRIDE].value : g_uiStride)
is the same as
if (model[STRIDE].isLogging) {
blah = model[STRIDE].value ;
} else {
blah = g_uiStride;
}
The ternary operator is as follows:
(condition) ? value_for_true_condition : value_for_false_condition
(model[STRIDE].isLogging == true ? model[STRIDE].value : g_uiStride) first checks to see if the isLogging == true, the (condition). If the condition is true the model[STRIDE].value value is used, if not true the g_uiStride value is used.
The statement as a whole checks the values on all those members of model, but only if the member .isLogging == true. Otherwise it uses the default value. Note that this statement will always be true if all members have .isLogging variable set to false.