Binary operations in Java

Hi,
are there any binary operations in Java like '&' in C? I didn't found any information in the API description.
Thank u.

You didn't find them from the API since they are a feature of the language. Try the langspec instead: http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#5228

Similar Messages

  • Java and binary operations (roll)

    Is there any roll operations in java?
    1011 rolled to the right would become 1101
    1011 rolled to the left would bcome 0111
    How can I accomplish this?

    Why do you need that?I'm making a huffman encoder and need binary paths. I shift individual paths into a long path, but when an individual path exceeds the total number of bits I need to store the highest bits into the remaining of the path. Its easier to mask the lower segment than the higher in a collection of bits, so I would like to roll the path to the high bits end up at the lower part of the path and then mask the path so it contains a correct number of bits and shift it into the remaining bits.
    example:
    current path - 10110010110010000
    path - 1000
    notice the three last bits (000). This is where I want to 'store' 1000. Since 1000 is four bits I need to take the 3 highest bits (100) store these and store the last bit in a new long path. I can mask the lowest by doing 'path &= ((int)Math.pow(2, bit) - 1)' but this is not possible with high bits.
    Nille

  • Binary operations

    Hi all,
    Okay im not very familiar with much binary operations, so I need a little help.  The problem that im having is the DAQ board im using has uses a 32 bit interface for digital I/O, and I need to be able to change  lines 8-22, depending on the decimal number and base the user enters and have that binary be in inverted logic.  For example if the user entered 486.6 with a step size of 0.05 the binary in regular logic would be 000000000 010011000000100 00000000 and in inverted logic 000000000 101100111111011 00000000 and I dont want the change of decimal affect any others lines of the code.  I think maybe for that I could just set a max limit for the decimal number to being 2^15-1, but not sure I can create this limit and shift in the binary in labview.  Any help would great, thanks.

    dbartz,
    Al of the logic primitives are polymorphic, meaning that you anc use them with numerical values. Set up your data as an unsigned 32 bit integer (U32). Use AND and OR functions to mask off the parts you want to change and the parts you want to protect. If you had 8-bit words (for a simplified example) and wanted to change bits 2, 3, and 4, you could do this:
    let K = old data (example K = 10101010)
    let P = new data (example P = 00111110) {Notice that P has non-zero values in bits other than 2, 3, 4}
    let Mk = mask for old data (example Mk = 11100011), and
    let Mp = mask for new data (example Mp = 00011100 = NOT Mk).
    Then (K AND Mk) OR (P AND Mp) = data to write.
    Using the example values above (K AND Mk) = 10100010, (P AND Mp) = 00011100, and data to write = 10111110.
    Lynn

  • Store a uploaded file of type binary into a java.sql.Blob

    Hi all,
    I try a File-Upload and store the file in a  java.sql.Blob of a MaxDB.
    My Problem is, that I'm not able to import a Model-Attribute of data type byte[]. Further I don't no how to convert the uploaded value attribute of data type binary, in a java.sql.Blob.
    Regards,
    Silvia Hofmann

    http://www.excelsior-usa.com/jet.html
    http://www.ej-technologies.com/products/exe4j/overview.html
    http://jsmooth.sourceforge.net/
    Distributing your Application as an executable JAR file
    Google is your friend.

  • In range and coerce binary operation

    How do I implment the "in range and coerce" function with binary operation?  I want to do that to make my fpga code more efficient.
    Kudos and Accepted as Solution are welcome!

    What exactly do you mean by "binary operation"?  I am assuming you are dealing with integers here to make life simple.
    The In Range portion is just a simple Less Than and a More Than with an AND ( x < UL && x > LL).  The Coerce portion would likely be best done with Select nodes based on the Less Than and the More Than comparisons.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • RS-232 binary operation

    Dear all,
    I am a researcher with commercial instrument.
    After communication with my technician, I got to know I have to do binary operation in RS-232.
    But I am not familiar with the binary operation.
    Could you please give me some solution about this by labview 6 or 7?
    I attah a part of the manual.
    *)please let me explain the meaning of the parameters.
    Host → Ecotec II: 5(start the communication), 5(length of the command, 5 bits),
    3 (RS-232 functional command), 0(parameter of the command), 13(checksum, 5+5+3+0).
    Very thank you for your attention.
    Any comments will be very helpful to me.
    Attachments:
    aaa.bmp ‏1129 KB

    Duplicate.
    Try to take over the world!

  • How to store binary data in Java

    I need to show news in my web aplication.So I am retrieving news from a Feed Server in which the field GEN_UNICODE_MESSAGE_1 gives the news data.News consists of both English/Arabic data.So how will I store the binary content in JAVA and how can I display the news in JSP?
    I tried storing the binary content in ByteArrayInputStream and appended it using StringBuilder.But I didnt get the desired output.Output is seen as ÇáÎáíÌíÉ ááÇÓÊËãÇÑÇáãÌãæÚÉÇáÔÑßÉÇáÇãÓÈÊãÈÑÓÈÊãÈÑÅÌãÇá.Please help me.
    Here GEN_UNICODE_MESSAGE_1 is of type BINARY.
    try{
    BufferedInputStream in=new BufferedInputStream(new ByteArrayInputStream((byte[])msg.getField("GEN_UNICODE_MESSAGE_1").value.get(h)));
    //ByteArrayInputStream in=new ByteArrayInputStream(((byte[])msg.getField("GEN_UNICODE_MESSAGE_1").value.get(h)));
    StringBuilder builder = new StringBuilder();
    byte[] buff=new byte[1024];
    int len;
    while ((len=in.read(buff))!=-1){
    builder.append(new String(buff,0,len));
    String incomingmsg=builder.toString();
    }catch(IOException e){}
    Edited by: Alance on May 7, 2010 10:12 PM

    BufferedInputStream bis=new BufferedInputStream(new ByteArrayInputStream((byte[])msg.getField("GEN_UNICODE_MESSAGE_1").value().toString().getBytes()));
    BufferedReader br = new BufferedReader(new InputStreamReader(bis));What on earth is all this?
    1. What is the type of msg.getField("GEN_UNICODE_MESSAGE_1").value()?
    2. Whatever that type is, you are then converting it to a String.
    3. You are then converting that to bytes.
    4. You are then casting that to byte[], which it already is,
    5. You are then wrapping a ByteArrayInputStream around that.
    6. ... and an InputStreamReader round that ...
    7. ... and a BufferedReader around that ...
    8. ... and reading lines
    9. ... and appending them to a StringBuilder
    10. ... and converting that to a String.
    Which you already at at step 2.
    String incoming = msg.getField("GEN_UNICODE_MESSAGE_1").value().toString();Not sure whether that's correct given the charset issues, but if not the problem starts at step 2. In any case steps 3-10 add precisely nothing.
    This is all pointless. The key question is (1). Answer that first.
    2. The type of String.getButy
    >
    StringBuilder sb = new StringBuilder();
    String line = null;
    while ((line = br.readLine()) != null) {
    sb.append(line + "\n");
    br.close();
    String incomingmsg=sb.toString();

  • Binary Sytem / binary operation

    I need any references (websites/PDFs) explainning binary sytem and binary operations (conversion,subtraction,division..)
    thanx in advance

    hi,
    try these:
    http://mindprod.com/jglossbinary.html
    http://www.learnbinary.com/
    for the last one click start in the top banner to start the tutorial, it's shown in an applet so it might take time to load depending on your connection.

  • Binary Operation in PL/SQL

    How do I do binary operations like or/and/xor in pl/sql? Are there any built-in libraries?

    I believe NOT x = -x - 1So NOT 19 = -20andNOT -8 = 7Hope this helps,
    T.

  • How can i do bitwise (binary) operations (AND, OR, XOR)

    I need to do bitwise (binary) operations such as AND, OR, and XOR.  For example, how do I AND 10101000 with 11111000?

    for OR, with 10101000 in A1 and 11111000 in A2, try:
      =1×SUBSTITUTE(A1+A2,2,1)
    Result:  11111000
    and for XOR, try:
       =1×SUBSTITUTE(A1+A2,2,0)
    Result: 1010000  (missing leading 0)
    You can display missing leading zeros by setting the cell's Data Format to 'Numeral System' with Base set to 10 and Places to 8, or turn the result into a string with something like this (assuming the result is in A3):
         =RIGHT("0000000"&A3,8)
    SG

  • Read binary file in java

    To read a text file i used
    FileReader reader=new FileReader("d:/a.txt");
    please guide me on how to read a binary file in java
    Any input would be greatly appreciated!
    Thanks in advance!
    Edited by: nikkj on Aug 7, 2010 7:36 PM

    I'll give you the quick answer: you use Readers for character streams (e.g., text files) and InputStreams for binary streams (e.g., binary files).
    Still, read the tutorial. You will find out lots of useful info.

  • How to convert numeric data to binary decimal in java

    How to convert numeric data to binary decimal in java Pleas egive me code example

    There is no numeric data. It's all binary. If you're talking about Strings, look at the Integer class.

  • Creating non binary trees in Java

    Hi everybody actually i am used in creating binary trees in java,can u please tell me how do we create non binary -trees in java.

    Hi,
    Can u let us know the application area for Non binary tree.
    S Rudra

  • Non binary trees in java

    Hi guys i am used in creating binary trees ,tell me how do we create non binary trees in java.

    public class Node {
      private final Object payload;
      private final Set<Node> children;
      public Node(Object payload) {
        this.payload = payload;
        children = new HashSet<Node>();
      // now add methods to add/remove children, a method to do something with the payload (say,
      // a protected method that passes the payload to a method specified by some kind of interface),
      // and methods to recurse over children.
    }Actually rather than using Object probably should have generic-ized the class, but whatever.

  • Creating Binary Files in Java

    Does anyone know how to create a binary file in Java.
    in C i can do an fopen("filename" , "rb") i cannot find a equivalent java binary file stream.
    Thanks

    The following code is part of my FileIO applet. This method allows the user to download any file from my server and save it on his/her disk, the download is accomplished by doing a byte-read and byte-write (byte mover as I'd call it). This example illustrates how you can read and write binary files in Java:
       public void aok_DownLoad(String inputFile, String outputFile) {
          try {
             URL url=new URL(inputFile);
             InputStream in;
             in=url.openStream();
             BufferedInputStream reader=new BufferedInputStream(in,4096);
             FileOutputStream out=new FileOutputStream(outputFile);
             BufferedOutputStream writer=new BufferedOutputStream(out,4096);
             byte[] buf=new byte[4096];
             int byteRead;
             while ((byteRead=reader.read(buf,0,4096))>=0) {writer.write(buf,0,byteRead);}
             reader.close();
             writer.flush();
             writer.close();
          catch (Throwable exception) {
             exception.printStackTrace();
       }V.V.
    PS: in this posting the code is posted in a different manner so that the > sign is not converted to & gt ; by the forum's software

Maybe you are looking for

  • Creation of DME medium FZ205 There is no source data found

    We are executing payment runs using F110 and then creating data medium - a file to send to the bank. In the variant for the program I am putting C:\ however when I have several users executing payment runs at the same time, the data medium is not cre

  • Error when changing the POV period of a recurring journal

    We recently upgraded from HFM 9.3.1 to 11.1.1.3 and are going through our first monthly close with the upgraded application. Everything had been working fine until today when one of the application administrators attempted to post a recurring journal

  • Gen2 ATV not visible in ITUNES 10.1.54, any others?

    Cable-connected. Have opened port 3689TCP and 5353UDP in NETGEAR FIREWALL. I can see ATV in the firewall, it gets syncronized, it has an IP, but not visible in ITUNES, Weird. I can see my library in ATV etc..my computer.. The ICON ATV in ITUNES was t

  • Track Multiple States(Moves) in a game

    Hello, For one of my classes, we are writing a Mancala game and have an undo button to take back 3 moves. I am using ObjectOutputStream to save the file and reload the saved file if someone clicks undo. The problem I am having is that I have to keep

  • Pipeline component for replace the values in send pipeline 837P

    hi friends, I am working in 837P splitting the claims.When i am sending using sendpipe line. I need  pass the 2010bb loop NM103 and NM109 defaluts values, ex: NM103=100,NM109=0123456789 like can you help me write pipeline component to manipulate the