Why get I 0 value unless I did conditional test - apache-pig

I want to filter an entiy where MT_V and MT_E should be diffenrent to zeo.
Note that these variables are declared as bigdecimal .
So the command is :
S0 = FILTER E1ECP BY ((NO_PCI != '0') AND (MT_V != 0) AND (MT_E != 0));
Where NO_PCI is an other variable.
But I get a line in my data where MT_V ==0.00 and MT_E == 0.00
PR,20190711-135040,2018,12,34,001,01,DC03520118,93873104,EUR,L,5A00,3A001,013400,806457,,,0.00,0.00,,2037,CAI,1600,,C1,
How do you explain this please ?

Use (int) to cast on MT_V,MT_E and compare it to 0.
S0 = FILTER E1ECP BY ((NO_PCI != '0') AND ((int)(MT_V) != 0) AND ((int)(MT_E) != 0));

Related

how do i correctly use >= and <= in code?

I have tried many thing involving this, >=, >==, =>, ==>.i can not find one that works. hey all return either primary expression needed or expected initializer before '>'. I am creating a IR receiver latch switch and thus have to create parameters for the code because the receiver is not constant in all conditions. Full code below. Any suggestions to fix the code please reply and don't DM me. Thank you.
code:
int LEDState = 0;
int LEDPin = 8;
int dt = 100;
int recieverOld ==> 500 and recieverOld ==< 2000;
int recieverNew;
int recieverPin = 12;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(LEDPin, OUTPUT);
pinMode(recieverPin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
recieverNew = digitalRead(recieverPin);
if((recieverOld >== 0 && recieverOld <== 10) && (recieverNew >== 500 && recieverNew <== 2000) {
if(LEDState == 0) {
digitalWrite(LEDPin, HIGH);
LEDState = 1;
}
}
recieverOld = recieverNew;
delay(dt);
}
error:
expected initializer before '==' token
if one = used line 4 and related, return error expected primary-expression before '>' token
if > before = line 4 and related, return error expected initializer before '>=' token
Any solutions or suggestions welcome.
TL;DR
Operators that do no exist, and that you should NOT use:
==>, ==<, >==, <==
Operators that works and you can use them:
>= - MORE THAN OR EQUAL, compare operator, for example X >= 5
<= - LESS THAN OR EQUAL, compare operator, for example X <= 5
> - MORE THAN, compare operator, for example X > 5
< - LESS THAN, compare operator, for example X < 5
== - compare operator, when you want to compare values of the variables if they have the same value, for example X == 5, Y == X, 10 == 7
=== - equality operator, similar to compare operator ==, but aditionally checks the type of a variable. for example X === Y, '10' === 10
= - assign operator, when you want to assign something to the variable, for example X = 5
<> OR != - NOT EQUAL, compare operator, for example X != 5, Y <> 10
!== - similar to != or <>, but also checks the type of a value. For example 10 !== '10', and will return opposite result of the equality operator ===

Check that a bitmask flag is zero [duplicate]

If I use this:
if(value & 4) to check if the bit is set, then how do I check if the bit isn't set?
I tried with
if(!value & 4) or if(~value & 4) and if(value ^ 4) but none of them works.
When you write if(value & 4), C checks the result to be non-zero. Essentially, it means
if((value & 4) != 0) {
...
}
Therefore, if you would like to check that the bit is not set, compare the result for equality to zero:
if((value & 4) == 0) {
...
}
You could do it many ways, but the easiest (easiest as in requires the least amount of thought) would be just negate the entire expression you already have:
if (!(value & 4))
Simply:
if ((value & 4) == 0)
Why?
If value is 01110011
Then
01110011
&
00000100
--------
Will return 0 because 4th bit is off.
the line from hastebin is poorly written, has unreachable code and depends heavily on the Precedence of the C operators. And doesn't work as expected.
The line from hastebin:
if( cur_w > source.xpos + source.width
&&
!(source.attributes & DBOX_HAS_SHADOW) )
{
break;
return;
}
it should be written as:
if( (cur_w > (source.xpos + source.width)) // has curr_w exceeded sum of two other fields?
&&
((source.attributes & DBOX_HAS_SHADOW) != DBOX_HAS_SHADOW ) //is bit == 0?
{
break;
}

while loop won't terminate even if i input a zero value for a and b

do
{
scanf("%d %d",&a,&b);
stcrnrArray[x] = a;
++a;
stcrnrArray[x] = b;
++b;
}
while((a != 0) && (b != 0));
while loop won't terminate even if i input a zero value for a and b
What is question? it will not terminate because u have given ++a; so its pre incrementing everytime thats why at the end (a != 0) condition satisfies..
if a = -1 and b = -1 the loop terminate

if statement gone wrong -xcode

Guys what am I doing wrong?
if (numberstring.intValue <=15) {
rankLabel.text = #"A1";
}
else if (numberstring.intValue >16 && <=40){
rankLabel.text = #"A2";
}
I get an error on the "<=40" ..
You missed off a variable reference:
if (numberstring.intValue <=15) {
rankLabel.text = #"A1";
} // vv here vv
else if (numberstring.intValue >16 && numberstring.intValue <= 40){
rankLabel.text = #"A2";
}
As an optional extra, it looks like numberstring is an NSString object, which you are repeatedly converting to an integer in order to test various ranges. That operation is quite expensive, so you are better off doing the conversion once:
int value = [numberstring intValue];
if (value <=15) {
rankLabel.text = #"A1";
}
else if (value >16 && value <= 40){
rankLabel.text = #"A2";
}
Also note that the intValue method is not a property so I would avoid using the Objective-C 2.0 dot syntax to access it and use the normal method calling mechanism.
The && operator links two clauses together. However, each clause is independent, so each one has to be syntactically correct on its own if the other was removed. If you apply this rule to your condition, you can see that "<=40" is not syntactically correct on its own. Thus you need to reference the value being compared, as follows:
if (numberstring.intValue > 16 &&
numberstring.intValue <= 40) // this is syntactically correct on its own

How do I express the "OR" logic operator in Objective-C?

Let's say that I want to check that one of two terms are effective, how do I express it?
if (value == 1 **--OR--** value == nil) {
do something;
}
||
eg: if (value == 1 || value == nil)