How do I achieve this in Node Red


This may seem absolutely easy task for someone out there but I'm stuck on this one.

I'm trying to achieve something in Node Red that has been done on Visual Basic.
A very simple scenario which could be understood by seeing the images below -
I have a combination of long integers in visual Basic which gives me zero or non zero values for certain combinations which when tried in Node Red with the same combinations doesn't give the desired results as those achieved in VB (Visual Basic)

This is what is has been done in VB

temp1, temp4, temp5, temp6 gives me zero, while
temp2, temp3 gives me non zero values in VB But same is not achieved in Node Red.

Node Red screen

And the Result......


Which should give me ZERO in Node Red (as this same combination in VB gives me zero) But I'm getting something else. How do I achieve this (result zero) ?

Also last question which is actually irrelevant here but someone from VB background may answer.

Why am I getting the non zero values for temp2 & temp3? can anyone explain please?


According to the bitwise comparison that you want to do is using & and not && in javascript.
Have you tried with just one & ?

1 Like

Additionally, in JavaScript || and && are boolean operators, so rather than bitwise you’re comparing them. There’s a large matrix somewhere out on the Internet explaining the specifics of boolean operators in JS per type and direction, but for bitwise you require the single character rather than double.
So what you see in your debug is the output of boolean comparison rather than bitwise operation. Hope that helps.

1 Like

Using only one & for bitwise comparison is giving the desired result.
Thank you all.
But when i tried to use this in an if /else or if/esle if statement I'm getting this error.


You want to many & and now you want to many = !!
Try removing one = :slight_smile:

Already tried with single = double == and === also but still problem


I think main problem is missing "," before statement which I fail to understand.

syntax is correct everything is correct despite this there is problem.

Sorry to bother you.

Nabbed the culprit

The I in if else was capital - If should have been if

Thanks for your support.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.