Expression node bit shift

Is this a bug or am I just thinking about this wrong?  The attached VI shows a U8 going through an expression node where the expression is "x << y".  I've tried multiple versions of y and as soon as y becomes large enough to shift all the original 1's off the U8, the result becomes 0xFF instead of 0x00.  I would assume that its intent was to match C's functionality since it matches C's syntax but this does not appear to be the case.
Any suggestions or is this a bug?
Thanks
Andy Brown
Averna
Attachments:
expression_shift_issue.vi ‏11 KB

Hey Andy,
Thank you for contacting National Instruments.  It does look like that is acting strangely.  However, we do have a Logical Shift VI that I believe accomplishes what you are looking for.
On the Block Diagram, go to Programming>>Numeric>>Data Manipulation>>Logical Shift.
It takes two inputs, x and y, with x being the original number, and y being the number of bits you want to shift.  It looks like it will clear out to 00 once all the bits have been shifted over.
Let me know if you any questions!
Regards,
Kevin H
National Instruments
WSN/Wireless DAQ Product Support Engineer

Similar Messages

  • Bit Complement in an Expression Node

    I can use bit complement in a formula node but not the expression node. The
    "~" tilde is the only text in the expression node. The error is "~#" with
    # being the error. The input is a U8. Thanks in advance for any help.

    Hi Catherine,
    I've tried your suggestion earlier and tried it again after your
    post but it still doesn't work. I am new to expression nodes so maybe my
    syntax is incorrect. To do the same in C language I think it looks like
    this: "a = ~ b;". I made a picture and a copy of the error. Let me know
    if you see anything wrong. Thanks!
    Error on line 1 is marked by a '#' character: "~#"
    [Image]
    Pat S.
    cfpautx wrote:
    > Hello Pat,
    > The way to fix this problem is fairly simple, if you change your
    > inputs and outputs to I8, u16 or I16 it will run correctly.
    > Regards,
    > Catherine Petronino
    > National Instrument
    > www.ni.com/ask

  • Problems with bit shift left in Formula Node

    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?
    Solved!
    Go to Solution.

    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
    R&D Engineer
    Pirelli Brazil

  • Expression node

    What is the correct syntax for an exponent with the expression node?
    I looked in LabVIEW help, and it looked like it was the '^' character,
    except that doesnt appear to be correct:
    The correct output should be 2, but LabVIEW returns 3.
    Cory K
    Solved!
    Go to Solution.

    Darin.K wrote:
    That is easily in my top 2 or 3 LV pet peeves.  I use exponentiation countless times and the next time I use bit-wise XOR in a LV text formula will be my first.  Why couldn't LV be like every other program/language I have used and use ^ for exponentiation?
    Define your definition of every other programming language!
    There are Ada, Bash, COBOL, Fortran, FoxPro, Gnuplot, OCaml, Perl, PL/I, Python, Rexx, Ruby, SAS, Seed7, Tcl, ABAP, Haskell (for floating-point exponents), Turing, VHDL which do just as LabVIEW, Algol, Commodore BASIC which use a special symbol ↑, and some like Java who don't even have a special exponentiation operator, but require the call of a math library function.
    BASIC, J, MATLAB, R, Microsoft Excel, TeX (and its derivatives), TI-BASIC, bc (for integer exponents), Haskell (for nonnegative integer exponents), Lua, ASP and most computer algebra systems do use indeed the ^ symbol, but in Bash, C, C++, C#, Java, JavaScript, Perl, PHP, Python and Ruby, the symbol ^ is used for the XOR operator and the LabVIEW formula node borrowed a lot of syntax from C and is in its current incarnation in fact a limited C syntax environment, so that leaves the ^symbol not available for the exponentiation anymore.
    Also I would say that LabVIEW is indeed more a programming language and not a computer algebra system.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Issue with bit shifting

    Hi everyone!
    I have a question about bit shifting. When I attempt to shift 32 bit on a int value, the output is the same value. It doesn't matter if I try to make a rigth or left shifting. It also hapend when I make 64 bit shifting on a long value. I supposed it should be 0. This is the code I'm woking with:
    int x = 2147483647;
    System.out.println("Output1 = " + (x >> 32));
    System.out.println("Output2 = " + (x << 32));
    Output:
    Output1 = 2147483647
    Output2 = 2147483647
    Could someone help me to understand why this happend?
    Thanks in advance.

    GerSua wrote:
    Hi everyone!
    I have a question about bit shifting. When I attempt to shift 32 bit on a int value, the output is the same value. It doesn't matter if I try to make a rigth or left shifting. It also hapend when I make 64 bit shifting on a long value. I supposed it should be 0. This is the code I'm woking with:
    int x = 2147483647;
    System.out.println("Output1 = " + (x >> 32));
    System.out.println("Output2 = " + (x << 32));
    Output:
    Output1 = 2147483647
    Output2 = 2147483647
    Could someone help me to understand why this happend?
    Thanks in advance.It is supposed to work this way. I know that's not alot of info, but you have not discovered a bug or anything like that.

  • Bit Shifting Help

    Hi,
    I'm not too familiar with bit shifting. If anyone can help with this problem, it would be great!
    We have words that are 32 bits. So, basically, the lower 8 bits should have value �1� and the upper 24 bits should have value �X�. For our example, lets say 5. How do you manipulate integers to get this format? So, I assume it will look like below.
    31 87 0
    00000000010100000001

    int i = 0x12345678;
    byte highOrder = (byte)(i >> 24);
    byte second = (byte)(i >> 16);
    byte third = (byte)(i >> 8);
    byte lowOrder = (byte)i;

  • Bug typedef does not connect to expression node

    Attached is a simple vi that tries to connect a typedef (in this case a double) to an expression node.
    Since LV8 this is not allowed anymore.
    We choose LabVIEW because it was possible to use it as a strict typed language. (one of the reasons).
    We see that the developers go a long way to make the language so easy that it is too strict to allow typedefinitions to an expression node.
    But it can also be a slip of the compiler of course.
    attached are the example vi and the typedef.
    please supply a patch because this makes it impossible for us to switch to LV8
    greetings from the Netherlands
    Albert Geven
    greetings from the Netherlands
    Attachments:
    typedef does not connect to expression node.vi ‏7 KB
    dbl typedef.ctl ‏5 KB

    A workaround is easy but should not be necessary because the typedef is used to keep it a typedef.
    Simply use an explicit type conversion in this case to [DBL], at least that was my guess....
    but an explicit conversion already knows there is nothing to do so it does not help.
    A typecast helps but sure that is not what I want, see picture below.
    greetings from the Netherlands
    Attachments:
    typedef bug not solved by explicit conversion.JPG ‏5 KB

  • IMAQ Array to Image Bit Shift?

    Hi,
    I've been working with some 12 bit images from a camera and saving the results as 16 bit TIFFs using some of the Vision VIs.  I can save and read back in the TIFFs and all of the data stays intact, but if I try to open the saved TIFFs in another reader (e.g. MATLAB), the returned data is incorrect.  Opening the raw TIFF files and looking at the image data (little endian) in bytes, numbers like 234 001 [490] end up becoming 234 129 [33258].  From the attached VI, it becomes clear there's a problem when you simply put in zeros to the array and try to open up the resultant TIFF in MATLAB (0 goes to 2^15) and yet LabView reads in the TIFF just fine.  While I can work around this problem, I only know I that need to work around it if I know a priori that the TIFF is from LabView.  Is there some resolution to this problem?  I'm thinking some kind of bit shifting to the data in LabView before converting the array to an image.  Thanks.
    Attachments:
    array_to_tiff.vi ‏49 KB

    Hello,
    Maybe you are looking for the functions "swap byte" and "swap words"
    Hope this helps
    Message Edité par TiTou le 06-29-2007 02:00 PM
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"
    Attachments:
    swap.png ‏409 KB

  • Polynomial in expression node

    I would like to enter the following equation into an Expression Node: 
    1 / ((1.376E-17*x^4) - (0.000000000000026254*x^3) + (0.000000000023901*x^2) + (0.0000000055134*x10) + 0.000000063412)
    However, each time I try I get block diagram errors.   I've tried removing spaces, parans, etc but have had no luck resolving the problem.  Any suggestions on how to do this or is there a different function in LabView that would be more appropriate?  Thanks.

    Hi JHess,
    what about rewriting the formula as:
    1 / ( (a*x)+b)*x)+c)*x+d)*x+e )
    with a to e your constants from left to right.
    It's just a different representation of the same formula. Your formula maybe doesn't work because of the "^" - powers should have to be written as "**".
    Using LabView primitives instead of the expression node may speed up your code as well!
    Message Edited by GerdW on 02-05-2008 09:51 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Expression node line too long

    Hi,
    I have an expression node which is very long.  How do I break it into multi-lines?
    Thank you in advance.
    Qing

    Hi Lucither,
    I tried but do not know how to do it.  Instead I attached my images of VI to you in a Word document.
    Thank you for help.
    Regards,
    Qing
    Attachments:
    HelpNI.docx ‏55 KB

  • Bit-Shifting vs. Math Ops

    I have always been under the impression that doing a bit shift is faster than I have always been under the impression that doing a bit shift is faster than performing the equivalent math operation when the math involves multiplying or dividing by a positive power of two. For instance, performing the following math op
    int i = 8;
    i = i << 3;
    System.out.println(i); //prints out the number 64should be faster than
    int i = 8;
    i = i * 8;
    System.out.println(i); //prints out the number 64The same applies when doing integer division (i.e. that a shift with zero fill to the right would be faster than performing the division operator).
    I have two questions:
    (1) Is there really a performance benefit to doing bit-shifting when it comes to integer math operations involving powers of two over using the regular multiplication and division operators?
    (2) If I perform the integer math ops using bit-shifting instead of using the traditional operators, how cross-platform is this kind of math? On my Windows machine, which apparently uses little Endian representation, the shifts perform as expected (i.e. << performs multiplication and >>> performs division on positive integer powers of two). However, if I run my code on a platform that encodes integers using big Endian, will the operations still perform as I expect, or am I unwittingly making my code platform-dependent?
    I appreciate any help you can offer me on this matter.
    -Dok

    Bit shifting seems to be used on integer operations with powers of two. Multiply or divide by 8 is being ran in the same amount of time as a bit shift of 3. However, if I change the 8 to a non-power of two like 7, then it takes longer. So these are optimizations being made by the compiler. However, these don't seem to apply to longs, and a long divide by 8 takes 4-5 times longer then a shift of 3.
    Also, I may be wrong, but I don't think you have to worry about a little Endian/big Endian representation. Bitwise operators seem to work fine on either platform (at least I haven't run into problems running them on multiple platforms).

  • Application Express node missing

    Hello experts,
    I have installed SQL Developer v. 1.5.5 Build MAIN-5969, connected to my application owner, but I can't find the Application Express node.
    Any tip?
    Tks
    Edited by: user12088893 on Oct 27, 2009 9:32 AM

    Hi Tks,
    Sorry for the late reply, this may not be of use anymore but someone else may get something from it.
    Is your install of Application Express 3.0.1 or higher?
    Oracle XE ships with Application Express 2.1.0.00.39. (You can upgrade Application Express to the latest version if you want).
    Here are some details
    http://www.oracle.com/technology/products/database/application_express/html/sql_dev_integration.html
    If you do have Application Express 3.0.1 or higher, then please post back and we can dig further.
    Thanks,
    Dermot.
    SQL Developer Team

  • Using an array with an expression node on a PDA

    I'm having a problem deploying an application to my PDA (pocket PC 2003) when the block diagram has an array wired to an expression node.
    When I try to build the exe I get the following error:
    retrun is a missing VI or C file.
    Attached is an example VI that produces the same error
    Thanks for the help.
    Eric
    LV 8.2
    PDA Module 8.2
    Attachments:
    Array w ExN.vi ‏11 KB

    Hello,
    This is an issue known prior to release - it is documented in the PDA Readme file:
    Open the LabVIEW Readme files folder by selecting Start»All Programs»National Instruments»LabVIEW 8.2»Readme, and then open readme_PDA.html.
    Search that html page for "expression node" (without quotes) and you should find this issue acknowledged as the 8th bullet under the section entitled "VIs and Functions Known Issues."
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Undocumented features of the expression node

    After investigating expression nodes in detail here, I stumbled on some undocumented features that could give your UIs some interesting new twists (if used in moderation!).
    I have not fully explored all possibilities, so there might be more.
    I have tested in it LabVIEW 4.0 through 2013SP1 and it seems to work everywhere. (Versions below 6i show some slight pixelation artifacts, but that can be ignored)
    Look what it can do!!!!
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    HiddenExpressions.png ‏8 KB

    Hornless.Rhino wrote:
    Hey wow, you can see through to the block diagram. Better put a perspex plate over that, you don't want animals getting in there and gnawing on the wires.
    Just duplicating the myRIO design, where you can see the "circuits" under a glass cover.
    LabVIEW Champion . Do more with less code and in less time .

  • Large scale bit-shifting

    Are there any libraries or reccomended techniques foir large-scale bit-shifting.
    I have a byte array (about 100KB). In the middle of the array, I need to insert 13 bits, and shift everyhting after those bits. The file format is not byte-aligned.
    Is there a "good" way to do this?
    Thanks,
    -Micah

    mtf wrote:
    Are there any libraries or reccomended techniques foir large-scale bit-shifting.
    I have a byte array (about 100KB). In the middle of the array, I need to insert 13 bits, and shift everyhting after those bits. The file format is not byte-aligned.
    Is there a "good" way to do this?I don't know of a library to do this, but it's pretty straightforward to implement, so long as you're clear about which end of the byte you consider to be the beginning (i.e., does the bit stream begin with bit 0 or bit 7 of a byte).

Maybe you are looking for

  • HT1461 I have installed the Windows 8 on my MacBook using BootCamp, but I cannot install drivers for Windows now

    I have installed the Windows 8 on my MacBook using BootCamp already, but I cannot install drivers for Windows now: I've got only BootCamp 3 disk and it doesn't goo even if I start it using compatibility options. And my BootCamp on Mac didn't offer me

  • How to merge 2 vbscript program into 1

    1st program code: Dim objShell Set objShell = WScript.CreateObject("WSCript.shell") objShell.run """C:\Program Files\Altiris\Altiris Agent\aexnsagent.exe"" /uninstall /qn" 2nd program code: strFolderName = "C:\Program Files\Altiris" Set fso = CreateO

  • Problem installing Windows 7(HELP ME!)

    Hi to everyone! I have an iMac 3.06 GHZ Intel Core 2 Duo that I bought in the early 2009 and yesterday I wanted to install Windows 7 because I have to run some Windows programs... I have had a problem when I partitioned and online they said to me to

  • Increase edit length in ALV GRID

    Hi All, I am using wa_fieldcat-edit for editing the ALV outreport. But here by editing i am able to enter only 10 characters in that filed. How can i increase this length upto 40 characters. Please help me in this. Regard, Kalyan Varma

  • Old pc new laptop

    I am one of the early ipod customers that had a battery problem a couple of years ago and had to send it back to Apple to have a new battery installed. When it was returned, all of my playlist were gone. I have an old pc with about 4000 songs. I have