LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bit and....bug?

Hi,

In may app I need to operate a bit AND operation
with a large mask (32 bit wise) in formula node.

If I use a mask that use the last bit (e.g. 0x8000000)
the operation return a wrong value, as the last bit
is used as a bit sign.

I have also specified the representation of the output
variable as U32 without success:

-------
uInt32 c;
c = a & b;
-------

a = 0x8000000
b = 0x8000000
c -> 0x7FFFFFFF

Instead I use a "normal" AND function (the graphical)
I get out a correct value of 0x80000000.

Seems that the implementation is not the same.....

p.s. verified on LV6 and 6.1

--
Francesco Pezzuti ICQ: 14253763
0 Kudos
Message 1 of 6
(3,180 Views)
Just did the same thing (I think..) here, works fine, see attached example...gives 0x8000000 from both the formula node and the graphical AND.

Mads
0 Kudos
Message 2 of 6
(3,180 Views)
I loaded your example, using LV 6.1 on Windows XP. The Formula Node
gives 7FFFFFFF when two 80000000 are given as the inputs.

Les Hammer
0 Kudos
Message 3 of 6
(3,180 Views)
Ah, I used 8000 000 as specified in the question and then the results are both correct and identical...but as you say - if you use 8 000 000 0 then the formula node seems to have a problem...

Not a fix to the formula node...but do you have to do that calculation in a formula node? If you have a lot of other calculations that makes it nice to use a formula node instead of pure G you could bypass the problem by doing the AND graphically either prior to the formula node or split the node into two nodes and do it in pure G between the two nodes...
0 Kudos
Message 4 of 6
(3,180 Views)
Mads wrote:
> Ah, I used 8000 000 as specified in the question and then the results
(snip)

Hi Mads,
yes, of course I have implemented a work around splitting the mask
and working only on 16 bit and it's work fine.


--
Francesco Pezzuti ICQ: 14253763
0 Kudos
Message 5 of 6
(3,180 Views)
Francesco Pezzuti wrote in news:b5v7u0$3pm2$1@ID-
11723.news.dfncis.de:

> Hi,
>
> In may app I need to operate a bit AND operation
> with a large mask (32 bit wise) in formula node.
>
> If I use a mask that use the last bit (e.g. 0x8000000)
> the operation return a wrong value, as the last bit
> is used as a bit sign.
>
> I have also specified the representation of the output
> variable as U32 without success:
>
> -------
> uInt32 c;
> c = a & b;
> -------
>
> a = 0x8000000
> b = 0x8000000
> c -> 0x7FFFFFFF
>
> Instead I use a "normal" AND function (the graphical)
> I get out a correct value of 0x80000000.
>
> Seems that the implementation is not the same.....

It seems that the implementation of unsigned int in the formula node is

completely wrong.

Have tried to use a signed int. For bit fiddling this is the same as
unsigned int. If you have or need a unsigned int outside the formula node
then use the conversion functions to get the inputs/outputs right.

(From my reading of your posting it seems that you have evaluated the use
of signed int, and it may be that you do more with the number than just bit
fiddling, but i can't tell without more information)

--
Rolf
0 Kudos
Message 6 of 6
(3,180 Views)