LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with bit shift left in Formula Node

Solved!
Go to solution

Hi,

Sorry but my English is not good.

 

I'm trying to execute a bit shift left in the Formula Node, but the shift left is not working as I expected.

 

 

uInt32 parametro[5];
float32 valorAmostra;
int16 indiceAmostra;
uInt8 indiceResposta;
int16 controle;
int32 valor;
int8 i;

for(i=0; i<5; i++)
    parametro[i]=param[i];

valor = parametro[5]<<16 | parametro[4]<<8 | parametro[3];
controle = parametro[1]<<8 | parametro[0];

indiceAmostra = (controle & 0x3FF);
indiceResposta = (controle >> 10);
    
valorAmostra = valor & 0x7FFFFF;   
valorAmostra = valorAmostra*(2.4/8388607);
   
   if((valor & 0x800000) == 0x800000)
      valorAmostra = valorAmostra*(-1);      

 

the input param array is of the type uInt8, as I saw in other topics that does not shift with uInt8,

 

I copy the values of param array to parametro which is of type  uInt32, but still did not work.

 

Testing the input param with the following values:

param[] = {10,14,10,0,16}

the valorAmostra returned is 0,00117188 when he should be 0,300003.

 

 

Can someone help me please?



0 Kudos
Message 1 of 2
(2,918 Views)
Solution
Accepted by topic author geovane

Portuguese:

 

Olá,

 

Existe um bug no LabVIEW para esta operação. Este bug deverá ser corrigido em versões futuras. Uma solução para esta situação é utilizar um int32 ao invés de um ulnt32.

 

Qualquer dúvida por favor entre em contato.

 

Obrigado.

 

 

 

English:

 

I investigated the problem you are having, and it turns out that it is a bug that has already been reported and documented. The work around for it is to use int32 rather than uInt32.

 

Thanks.

Luciano Borges
Test Development Engineer
Message 2 of 2
(2,895 Views)