Binary/bit-operation

hi folks,
i would like to do the following:
i have a byte and split it up to get the left and right half of the byte. then i xor the left with the right and replace the right with the result of the xor.
how can i do this ?
here some code to get the half bytes:
byte temp = (byte)140; // or any other byte-value
int left = (temp & 0xF0) / 16; // get the left half-byte
int right = temp & 0x0F; // get the right half-byte
int xor = left ^ right; // xor the left with the right
// how shall i go on to replace the right with the xor-result ?thanks a lot,
tobias

Is this what you want?
byte result = (byte)((temp & 0xF0) | xor);

Similar Messages

  • Bit Operations

    I'm attempting to do some bit operations on a decimal value that I need to output as binary to my instrument. Using universal libraries Digital out vi, I can send an integer value out as a binary number. Is it possible to perform bit operations on a decimal value using the formula node and logical operators? I need to make the LSB, the MSB. For example, a decimal value of 128 in binary is 10000000. I would need to output this as 00000001. I was trying to use a formula node like this: y = (x && 1) ? 128:0 ..... y = (x && 128) ? 1:0 for all the eight bit values. Then I would add all the values up and send that to DOUT. So in my example beginning with a decimal value of 128 and sending it to eight formula nodes I would like to get false values unti
    l y = (x && 128) ? 1:0. Then the compound addition would yield one and this value would be sent out to my instrument as binary 00000001. Unfortunately, I get true values out of all my formula nodes. How can I accomplish the bit operations I need to perform on a decimal value and then send it as an integer value to DOUT? The example is simplified, the actual decimal values are large. Any help would be greatly appreciated.

    I don't know about the formula node but you could just use a few labview functions. Change it into an array of bits using number to boolean array and boolean to (0,1). Use reverse array and then change it back to a number using 'not equal to zero?' and boolean array to number. Not sure if that is better or simpler than using a formula node but it is another option.

  • ID3v2: Programmers' habits when describing bit-operations

    Hi.
    I'm trying to implement a class that can read ID3v2 tags from MP3 files. The id3.org site seems to be the only source on the net where you can get information about the organisaton of ID3 tags.
    Unfortunately I haven't worked with bit operations before and get quite confused about the fact why so many programmers describe the order of bits in octal values.
    Let me quote a part of the description of ID3v2:
    The ID3v2 tag size is encoded with four bytes where the most significant bit (bit 7) is set to zero in every byte, making a total of 28 bits.
    I could understand that part. But the following leaves a huge question mark over my head...
    The zeroed bits are ignored, so a 257 bytes long tag is represented as $00 00 02 01. ... An ID3v2 tag can be detected with the following pattern:
    $49 44 33 yy yy xx zz zz zz zz
    Where yy is less than $FF, xx is the 'flags' byte and zz is less than $80.
    Can somebody of the veterans try to help me understand the first line, where the author describes in octal basis how these four bits are structured? Moreover I'd like to know what advantages it has to express bytes in octal values.
    Regards,
    Wan-Hi

    ...why so many programmers describe the order of bits in octal values.I doubt it. The endianness of data is either big-endian or little-endian (x86).
    The ID3v2 tag size is encoded with four bytes where
    the most significant bit (bit 7) is set to zero in
    every byte, making a total of 28 bits.
    The zeroed bits are ignored, so a 257 bytes long
    tag is represented as $00 00 02 01.
    That's not octal. it's hexadecimal.
    0x00 0x00 0x02 0x01
    In binary
      0000 0000 0000 0000 0000 0010 0000 0001
    Strip out the msb in each byte
      x000 0000 x000 0000 x000 0010 x000 0001
    and you you are left with 28 bits
      0000000000000000000100000001
    or
      0000 0000 0000 0000 0001 0000 0001
    or in hexadecimal
      0x0000101
    or in decimal
      257

  • Understanding Bit operations

    I'm going through the Sun tutorial on bitwise operators and I think I'm missing something. They say to use bitwise operations in place of creating multiple boolean variables. They set a series of integer variables to different powers of 2 like this :
    static final int READY = 1;
    static final int PROCESSING = 2;
    static final int RECOVERING = 4;
    static final int ERROR = 8;
    and then define another integer variable whose bits will represent the different switches. like this:
    int indicators = 7
    then then go on to test the different switches like so :
    if ((indicators & READY) == READY)
    what I don't understand is why they are doing the (indicators & READY) comparison. My understanding of the & operator was that it was used to return true if both items are boolean and true, however they are not boolean they are integers so I don't understand whats going on by this statement. Can someone please explain this to me so that I can understand what they're actually accomplishing?

    '&&' is a binary conditional operator that compares two boolean expressions and returns true if both evaluate to true and false otherwise.
    '&' is a binary bitwise operator that does a bitwise and logical operation on two numerical values and returns a numerical value that has bits set (1) when both operands had set bits, and bits reset (0) otherwise.
    When using bitwise '&', to get a boolean value, the result of the bitwise operation has to be compared to another numerical value, typically with a single bit set, using the '==' operator, to return a boolean value.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Binary, Bits and Hexidecimal

    I am developing code to decode handphone PDU.
    I need to decode the hexidecimal in the PDU into binary bits first.
    Then I need to take every 7 bits and form them into a character.
    E.g. A201 will give 1010 0010 0000 0001
    so the code will have to return 0100010 as ASCII for the first character, 1100000 as ASCII for the second character.
    How can I go about doing that in the most efficient method.
    I was thinking about converting to string first (0's and 1's), then manually extract out every 7 bits and do the processing. But that looks quite tedious.
    Can anybody comment on this. Thanks!

    Can't see where the 1100000 comes from.
    Have you really got characters on 7 bit boundaries? That would be very unusual and inconvenient.
    This kind of bit manipulation is best tackled with shift and mask operations of which this will be a particularly tiresome example. You need to load your hex data into an array of, I would suggest, ints, loading two hex digits at a time. Work in blocks of 7 bytes (7 bytes becomes 8 characters).
    int[] codes = new int[7];
    String hex = "a7882312228823"; // say
    for(int i = 0; i < 7; i++)
         codes[i] = Integer.parseInt(hex.substring(2 * i, 2 * i + 2);Then you need to extract the characters by combining the appropriate bits from each byte of data.
    char output = new  char[8[;
    output[0] = (codes[0] >> 1);   // first 7 bits of code 0
    output[1] = (codes[0] << 7) | (codes[1] >> 2); // bottom bit of first and 6 bits from second
    output[2] = (codes[1] << 6) | (codes[2] >> 3); // bottom 2 bits of second and top 5 from third
    ... etc ...Of course it's a lot messier than this because your data might not be a multiple of 7 bytes and the data supply is obviously more complicated.

  • How can I install after effects on 32 bit operating system?

    How can I install after effects on 32 bit operating system?
    I cant even find it in creative cloud.
    I want to make  a intro but it dossent allow me to even find/ istall it.
    I hope some one will help me by anwsering my question.
    Than you for time.

    If your system does not meet the minimum system requirements you have to go back to a version that does. Try the direct download links you'll find here.. CS5 comes bundled with CS4 for AE which is the last  version to run on a 32 bit system.

  • Nqs error 59001: Binary logical operation error in OBIEE 11g

    Hi,
    Requirement: Need to calculate YTD for invoiced amount and Prior YTD for invoiced amount and last year total invoiced amount.
    Logic we used: For YTD Invoiced amount we used “Year To Date” time series function in rpd.
    For Prior YTD we used “Ago function on Calculated YTD column”.
    For Last Year Invoiced amount we used “ CASE function and dynamic variables” as:
    CASE WHEN year=valueOf(previous_year) THEN invoiced_amount END;
    Now, when I’m creating a report, I’m getting the following error as:
    *[nQSError: 43119] Query Failed: [nQSError: 59001] Binary Logical operation is not permitted on VARBINARY, INTEGER operand(s). (HY000)*
    Please help me to solve this, i need to release the instance by EOD

    Hi,
    As per my understanding the ValueOf(previous_year) is double precesion so it wont allow to use binary logical operator.Change to integer becos we can manage year with interger data type.
    [nQSError: 59001] Binary Logical operation is not permitted on DOUBLE PRECISION, VARBINARY operand(s).
    mark if helpful/correct
    thanks,
    prassu

  • New iTunes still not working with 64 bit operating systems?

    When will iTunes support advanced 64 bit operating systems...
    Would seem that a next generation phone would work with the next generation of operating systems...

    iTunes does work with vista 64 bit. I can sync my iPod with it. It's the 'Apple Mobile Device Support' portion that is required by the iPhone that isn't working.

  • HP business inkjet 2800 Print black only option not showing in Windows 7 64 bit operating system

    HP business inkjet 2800 Print black only option not showing in Windows 7 64 bit operating system
    Please help, if any one knows any solution.

    Hi @Firoskhan,
    Welcome to the HP Forums!
    I am sorry, but to get your issue more exposure I would suggest posting it, in the commercial forums since this is a commercial product. You can do this at HP Enterprise Business Community.
    Hope this helps!  
    RnRMusicMan
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to say “Thanks” for helping!

  • HP Laserjet p2015d auto duplex printing with Windows 7 64 bit operating system

    I have used the HP Laserjet p2015d with Windows 7 32 bit operating system and have been able to use the AUTOMATIC DUPLEX feature of the printer without problems.
    Now, however, I have installed the 64 bit version of Windows 7 operating system and the AUTO DUPLEX does not work and is not shown as being available on the PROPERTIES menu of the printer.
    Is it possible to use the AUTO DUPLEX  feature of  the printer with Windows 7   64 bit  operating system.
    All replies welcomed!   Aaron in Calif.

    Hi Aaron,
    Make sure the Automatic Duplexing option is enabled:
    Enter Control Panel > Devices and Printers.
    Right click the printer icon, then click Printer Properties.
    Click the Device Settings tab.
    Set the Automatic Two-Sided Duplex Accessory as installed and click OK to save the change.
    Now Automatic Duplexing should become available.
    Regards,
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • Ram utilization with 64 bit operating system

    Attached is the current configuration of my 8.1 Pro PC & I have a question regarding RAM utilization with 32 bit programs running on this PC.
    It has been my understanding that the 32 bit OS (XP Pro), at best, would be able to only utilize 4GB of RAM memory.  
    I've recently built a PC for the specific task of running an application which is very CPU & output intensive. The application is a Windows based 32 bit application which analyzes and recovers data from NAND chips.  Input data comes from a 2.0 USB
    feed, is processed and is then written to a 2 disk raid array.
    Will the 64 bit operating system enable 32 bit applications to utilize more than 4GB of RAM memory?  Any suggestions on how to maximize the processing of 32 bit application on a 64 bit OS would be appreciated.
    Operating System
    Windows 8.1 Pro 64-bit
    CPU
    Intel Xeon E3 1275 v2 @ 3.50GHz
    35 °C
    Ivy Bridge 22nm Technology
    RAM
    16.0GB Dual-Channel DDR3 @ 657MHz (9-9-9-24)
    Motherboard
    Supermicro X9SAE (CPU)
    37 °C
    Graphics
    HP w2408 (1920x1200@59Hz)
    Intel HD Graphics (Super Micro Computer)
    Storage
    372GB Western Digital WDC WD4000AAKS-00TMA0 (SATA)
    30 °C
    465GB Western Digital WDC WD5000HHTZ-04N21V0 (SATA)
    28 °C
    465GB Western Digital WDC WD5001ABYS-01YNA0 (SATA)
    32 °C
    465GB Western Digital WDC WD5003ABYX-01WERA1 (SATA)
    31 °C
    Optical Drives
    PLEXTOR DVDR PX-891SAW
    TSSTcorp CDDVDW SH-224DB
    Audio
    High Definition Audio Device

    Hi,
    As far as I know, 32-bit application running on x64 Windows system had a limit of memory address space. The max usage of RAM is 4GB. I also make a test using testlimit:
    According to the screenshot, we can find that, 32-bit testlimit only can leak 4051MB memory, while 64bit testlimit can achieve to 5200 even more larger memory.
    For more information about this knowledge, you can refer to contents of chapter 9 in Windows Internal:
    http://live.sysinternals.com/WindowsInternals/WindowsInternals-Ch05.pdf
    Roger Lu
    TechNet Community Support

  • Can you tell me if I have a 64 bit operating system which Java update do I download

    Please can anyone advise me on what Java update I download for a Windows 7 64 bit operating system. My Firefox is telling me I need to urgently update my Java but when I click through to update all that is there is a page of confusing information about 32 bit and 64 bit systems. It asks which version am I using 64 bit version of Firefox or 32 bit. I didn't know there were two, I thought when referring to 64 bit and 32 bit it meant the operating system of my computer. Can anyone clear this up for me. Thank you.

    Of course, if you have a x64 bit system, its better to download a x64 bit Java version. However, i think Firefox won't be able to use it since Firefox isn't x64 bit (yet). So if you need Java in your browser, you'll need Java's 32bit version.
    Keep in mind i could be wrong. It's just my guessing because i tried it out some months ago. I installed 64bit Java but Firefox couldn't handle it.
    However in my opinion you won't recognize a difference between 32 and 64 bit, unless you play games in Java or do other resource intensive work. 32bit will always work on a 64bit PC, but not the other way around.

  • Hi everyone.. I have windows 7 (32 bit operating system), and have tried installing the latest version of Itunes, but my PC keeps saying windows 7 error (126) ? I have no idea on how to fix this??

    hi everyone.. I have windows 7 (32 bit operating system), and have tried installing the latest version of Itunes, but my PC keeps saying windows 7 error (126) ? I have no idea on how to fix this??
    Please could someone help???
    And it also mentions mediatoolbox dll. is missing?? haha i have no idea what that means??? please help...
    Thanks alot! I really appreciate your help..

    Try the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • HT2305 I have Widows 8 but my Itunes wont open I keep getting a message "Itunes software does not install on 64 bit operating system"

    I have a Widows 8 laptop. I cant open Itunes. I get a message "Itunes software does not install on 64 bit operating system" Can anyone tell me how to get it installed?

    If you are referring to Vista Support, It may be after the new year before it fully supports vista. I have not upgraded to vista yet but I was thinking about it!

  • [SOLVED]Can I run a 64 bit operating system?

    I want to know if I can run a 64 bit operating system on my laptop. the lshw command says I have a 64 bit processor, so does that mean I can run a 64 bit O.S. because  almost everything else says 32 bit. So, does all my hardware have to be 64 bit, or is it only the processor that matters? I have looked on the internet and it always seems to relate only to the processor, so I don't know if the other stuff matters. My laptop came with 32 bit vista, if that matters. Sorry if this is a stupid question. Thanks.
    Last edited by Tux the penguin (2010-11-23 20:01:40)

    Thanks for the quick reply. Sorry. I should have been more clear. By everything else I meant for example:
    *-pci:1
    description: PCI bridge
    product: MCP79 PCI Express Bridge
    vendor: nVidia Corporation
    physical id: 10
    bus info: pci@0000:00:10.0
    version: b1
    width: 32 bits
    clock: 33MHz
    capabilities: pci pm msi normal_decode bus_master cap_list
    resources: ioport:d000(size=4096) memory:faf00000-fbffffff ioport:e0000000(size=402653184)
    -storage
    description: SATA controller
    product: MCP79 AHCI Controller
    vendor: nVidia Corporation
    physical id: b
    bus info: pci@0000:00:0b.0
    logical name: scsi0
    logical name: scsi1
    version: b1
    width: 32 bits
    clock: 66MHz
    capabilities: storage pm msi ahci_1.0 bus_master cap_list emulated
    configuration: driver=ahci latency=0 maxlatency=1 mingnt=3
    resources: irq:42 ioport:c000(size=8) ioport:bc00(size=4) ioport:b880(size=8) ioport:b800(size=4) ioport:b480(size=16) memory:fae72000-fae73fff
    *-multimedia
    description: Audio device
    product: MCP79 High Definition Audio
    vendor: nVidia Corporation
    physical id: 8
    bus info: pci@0000:00:08.0
    version: b1
    width: 32 bits
    clock: 66MHz
    capabilities: pm bus_master cap_list
    configuration: driver=HDA Intel latency=0 maxlatency=5 mingnt=2
    resources: irq:21 memory:fae78000-fae7bfff
    *-network
    description: Ethernet interface
    product: MCP79 Ethernet
    vendor: nVidia Corporation
    physical id: a
    bus info: pci@0000:00:0a.0
    logical name: eth0
    version: b1
    serial: 00:24:21:6d:a4:82
    capacity: 1Gbit/s
    width: 32 bits
    clock: 66MHz
    capabilities: pm bus_master cap_list ethernet physical mii 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
    configuration: autonegotiation=on broadcast=yes driver=forcedeth driverversion=0.64 latency=0 link=no maxlatency=20 mingnt=1 multicast=yes port=MII
    resources: irq:20 memory:fae7d000-fae7dfff ioport:c080(size=8) memory:fae7e800-fae7e8ff memory:fae7e400-fae7e40f
    description: Notebook
    product: CR600 (To Be Filled By O.E.M.)
    vendor: Micro-Star International
    version: Ver 1.000
    serial: System Serial Number
    width: 32 bits
    capabilities: smbios-2.6 dmi-2.6 smp-1.4 smp
    configuration: boot=normal chassis=notebook cpus=2 family=To Be Filled By O.E.M. sku=To Be Filled By O.E.M. uuid=00020003-0004-0005-0006-000700080009
    Processor details-
    *-cpu:0
    description: CPU
    product: Pentium(R) Dual-Core CPU T4200 @ 2.00GHz
    vendor: Intel Corp.
    physical id: 4
    bus info: cpu@0
    version: 6.7.10
    serial: 0001-067A-0000-0000-0000-0000
    slot: CPU 1
    size: 2GHz
    capacity: 2GHz
    width: 64 bits
    clock: 200MHz
    capabilities: x86-64 boot fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm xsave lahf_lm
    configuration: cores=2 enabledcores=2 id=1 threads=2
    So, I could still run a 64 bit OS, even though most of the hardware is 32 bit?
    Last edited by Tux the penguin (2010-11-23 02:57:18)

Maybe you are looking for

  • When printing an AutoCAD-exported PDF file, the paper version has lines that screen does not show

    Hello, We were contacted by our customer, a landscape architectural company that uses our product, M-Color, (http://m-color.com) to plot AutoCAD drawings with required preferences and effects. However, they provided us with a sample PDF files, that c

  • 500 SAP Internal Server Error, in WD report while launching SC in SRM 7.01

    Dear SAP WD Gurus, We have recently upgraded the SRM 7.0 to EHP1 after that we are getting ths below We have created Z WD application genarating report in SRM 7.0, we have provided a hytep link in row to display shopping cart in the report. on click

  • Errors in Kernel logs on my RV120W

    Hello, after succesfully update to version 1.0.5.6, I have errors in my log. I made a factory reset after update and manualy set everything. I have cable internet connection, DHCP server in Cisco, use wifi and I have a few firewall and forwarding rul

  • Not showing web pages

    Firefox is not showing any page; all the content is in absolute white; the source code is the same. The Antivirus and the spyware is not detecting any issue in the machine. The others browsers are working normally. I tried to unnistall the software,

  • Equalizer problem after lollipop update

    Hi. I just noticed that equalizer is only working with walkman app. It worked just fine in kitkat.