Binary addition,subtraction and modulo operations.

Query:
Take two 512 bit numbers passed as strings. don't use biginteger!
convert them to binary without using parseInt or toString functions.! you may use char array and byte arrays.
then add these two binary numbers using binary addition logic.
display the result in decimal format back again.
Is it possible to perform this operation like this!!if yes,then please tell how should i approach with my existing code.
thanks.
package bytearrayopeations;
import java.math.BigInteger;   
public class binaryadding {
    public static void main(String[] args) {
        BigInteger a = new BigInteger("123456");
        BigInteger b = new BigInteger("5121");
        String bb1 = a.toString(2);
        String bb2 = b.toString(2);
        String ss1 = null;
        String ss2 = null;
        String result = "";
        String carry="0";
        System.out.println("first value=" +bb1);
        System.out.println("second value=" +bb2);
        int k=bb1.length();
        int h=bb2.length();
        System.out.println("length 1="+ k);
        System.out.println("length 2=" +h);
        int p=h-k;
        //System.out.println("difference=" +p);
        int q=k-h;
        //System.out.println("difference 2=" +q);
        if(h==k)
       else if(h>k)
            for(int i=0;i<p;i++)
                bb1="0"+bb1;
            System.out.println("new value of first=" +bb1);   
    else if(h<k)
        for(int i=0;i<q;i++)
            bb2="0"+bb2;
        System.out.println("new value of second=" +bb2);
        StringBuffer sb1=new StringBuffer(bb1);
     StringBuffer sb2=new StringBuffer(bb2);
        bb1=sb1.reverse().toString();
     bb2=sb2.reverse().toString();
        //System.out.println("rev. buffer1=" +bb1);
        //System.out.println("rev. buffer2=" +bb2);
        for(int i=0;i<bb1.length();i++)
            ss1=bb1.substring(i,i+1);
            ss2=bb2.substring(i,i+1);
          System.out.println("value1=" + ss1 + "    " + "value2=" + ss2);
          if (ss1.equals("0") && ss2.equals("0")) 
             if (carry.equals("0")) 
                 result+="0";
                    else
                        result+="1";
           else if (ss1.equals("1") && ss2.equals("1"))
            if (carry.equals("0")) 
                result+="0";
          carry="1";
          else
               result+="1";
               carry="1";
    else if (ss1.equals("0") && ss2.equals("1"))
                 if (carry.equals("0")) 
                     result+="1";
               carry="0";
                    else
                      result+="0";
                                carry="1";
           else if (ss1.equals("1") && ss2.equals("0"))
                 if (carry.equals("0")) 
                    result+="1";
                    carry=" 0";
               else
                            result+="0";
                            carry="1";
       System.out.println("sum=" +result + "         " + "carry" + carry);
                    result+=carry;
                    StringBuffer sb3=new StringBuffer(result);
                    result=sb3.reverse().toString();
                System.out.println("result is " +result); 
              System.out.println("Binary = "+ result + ", Decimal = "+Integer.parseInt(result,2));
}

bansal.s, you have been warned. I am now blocking your account for a month.

Similar Messages

  • Java program to perform binary addition,subtraction and modulus.

    i am a newbie to java and require ur urgent help plzzzz.
    i wanna perform binary addition,subtraction and modulus operation between two numbers of 512 bit without using java functions i.e by simple logics of control statements.i need to convert two 512 bit numbers passed as string into binary form, and then perform addition,subtraction and modulus operations on these two binary numbers and finally dipaly the result in decimal format.
    i think we may use full adder binary logic in this!!!
    please send me the java coding for these three operations as urgent as possible on my email.
    i would be highly obliged.
    thanks.
    sheetal.

    i have managed to make this code myself but i wanna learn the basics...so plz help me guyz...
    this is the code:
    package bytearrayopeations;
    import java.math.BigInteger;
    * @author sheetalb
    public class binaryadding {
    public static void main(String[] args) {
    BigInteger a = new BigInteger("123456");
    BigInteger b = new BigInteger("5121");
    String bb1 = a.toString(2);
    String bb2 = b.toString(2);
    String ss1 = null;
    String ss2 = null;
    String result = "";
    String carry="0";
    System.out.println("first value=" +bb1);
    System.out.println("second value=" +bb2);
    int k=bb1.length();
    int h=bb2.length();
    System.out.println("length 1="+ k);
    System.out.println("length 2=" +h);
    int p=h-k;
    //System.out.println("difference=" +p);
    int q=k-h;
    //System.out.println("difference 2=" +q);
    if(h==k)
    else if(h>k)
    for(int i=0;i<p;i++)
    bb1="0"+bb1;
    System.out.println("new value of first=" +bb1);   
    else if(h<k)
    for(int i=0;i<q;i++)
    bb2="0"+bb2;
    System.out.println("new value of second=" +bb2);
    StringBuffer sb1=new StringBuffer(bb1);
         StringBuffer sb2=new StringBuffer(bb2);
    bb1=sb1.reverse().toString();
         bb2=sb2.reverse().toString();
    //System.out.println("rev. buffer1=" +bb1);
    //System.out.println("rev. buffer2=" +bb2);
    for(int i=0;i<bb1.length();i++)
    ss1=bb1.substring(i,i+1);
    ss2=bb2.substring(i,i+1);
    System.out.println("value1=" + ss1 + " " + "value2=" + ss2);
    if (ss1.equals("0") && ss2.equals("0"))
    if (carry.equals("0"))
    result+="0";
    else
    result+="1";
    else if (ss1.equals("1") && ss2.equals("1"))
    if (carry.equals("0"))
    result+="0";
              carry="1";
              else
                   result+="1";
                   carry="1";
    else if (ss1.equals("0") && ss2.equals("1"))
    if (carry.equals("0"))
         result+="1";
                   carry="0";
                        else
                        result+="0";
    carry="1";
    else if (ss1.equals("1") && ss2.equals("0"))
    if (carry.equals("0"))
    result+="1";
    carry="0";
                   else
    result+="0";
    carry="1";
    System.out.println("sum=" result " " + "carry" + carry);
    result+=carry;
    StringBuffer sb3=new StringBuffer(result);
    result=sb3.reverse().toString();
    System.out.println("result is " +result); 
    System.out.println("Binary = "+ result + ", Decimal = "+Integer.parseInt(result,2));
    plz reply nw...

  • Binary addition,subtraction and modulus...plz help urgent

    plz help me on this query...
    i need to pass two 512 bit number as string,then convert them to binary and
    then perform binary addition,subtraction,modulus operations on those two numbers.finally convert result to integer.
    i designed a code which doesnt work correct.it is:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package bytearrayopeations;
    import java.math.BigInteger;   
    * @author sheetalb
    public class binaryadding {
        public static void main(String[] args) {
            BigInteger a = new BigInteger("123456");
            BigInteger b = new BigInteger("5121");
            String bb1 = a.toString(2);
            String bb2 = b.toString(2);
            String ss1 = null;
            String ss2 = null;
            String result = "";
            String carry="0";
            System.out.println("first value=" +bb1);
            System.out.println("second value=" +bb2);
            int k=bb1.length();
            int h=bb2.length();
            System.out.println("length 1="+ k);
            System.out.println("length 2=" +h);
            int p=h-k;
            //System.out.println("difference=" +p);
            int q=k-h;
            //System.out.println("difference 2=" +q);
            if(h==k)
           else if(h>k)
                for(int i=0;i<p;i++)
                    bb1="0"+bb1;
                System.out.println("new value of first=" +bb1);   
        else if(h<k)
            for(int i=0;i<q;i++)
                bb2="0"+bb2;
            System.out.println("new value of second=" +bb2);
            StringBuffer sb1=new StringBuffer(bb1);
         StringBuffer sb2=new StringBuffer(bb2);
            bb1=sb1.reverse().toString();
         bb2=sb2.reverse().toString();
            //System.out.println("rev. buffer1=" +bb1);
            //System.out.println("rev. buffer2=" +bb2);
            for(int i=0;i<bb1.length();i++)
                ss1=bb1.substring(i,i+1);
                ss2=bb2.substring(i,i+1);
              System.out.println("value1=" + ss1 + "    " + "value2=" + ss2);
              if (ss1.equals("0") && ss2.equals("0")) 
                 if (carry.equals("0")) 
                     result+="0";
                        else
                            result+="1";
               else if (ss1.equals("1") && ss2.equals("1"))
                if (carry.equals("0")) 
                    result+="0";
              carry="1";
              else
                   result+="1";
                   carry="1";
        else if (ss1.equals("0") && ss2.equals("1"))
                     if (carry.equals("0")) 
                         result+="1";
                   carry="0";
                        else
                          result+="0";
                                    carry="1";
               else if (ss1.equals("1") && ss2.equals("0"))
                     if (carry.equals("0")) 
                        result+="1";
                        carry="0";
                   else
                                result+="0";
                                carry="1";
           System.out.println("sum=" +result + "         " + "carry" + carry);
                        result+=carry;
                        StringBuffer sb3=new StringBuffer(result);
                        result=sb3.reverse().toString();
                    System.out.println("result is " +result); 
                  System.out.println("Binary = "+ result + ", Decimal = "+Integer.parseInt(result,2));
    }plz provide me or email me if possible java coding for all three operations as soon.
    [email protected]

    One thread is enough. Continue here:[http://forums.sun.com/thread.jspa?threadID=5373720&messageID=10643157#10643157]

  • If any function like greatest or least for addition,subtraction and multi?

    if any function like greatest or least for addition,subtraction and multi?
    there are two columns 'a' and 'b'...i have to add the values in column wise
    a b add
    10 30 -->40
    20 40 -->60
    IS there any function?

    Hi,
    794244 wrote:
    if any function like greatest or least for addition,subtraction and multi?
    there are two columns 'a' and 'b'...i have to add the values in column wise
    a b add
    10 30 -->40
    20 40 -->60
    IS there any function?Do you mean something like
    FUNCTION_X (a, b, c, d, ...)that would return the sum of all those numbers?
    No, not that I know of. If there were, it would be harder to use than
    a + b + c + d + ...The first is a comma-delimited list of columns, with a function name and parentheses.
    The second is a +-sign delimited list, with nothing else needed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Name and Address operator's packge do not have any values

    Hi All,
    I am using the Name and Address operator, but I do not have/want the 3rd party vendor's connector/tool/data library to work with my OWB.
    I developed the map and deployed that map into my target.
    Package got generated of name NAME_ADDRESS
    In this package the entry point is the MAIN function, in the main function taking one parameter p_env.
    When I execute the Package from SQL*Plus I am getting the value of p_env, which is wrong, p_env can not be NULL/0 at any case.
    All I want is, how to pass/populate the value into p_env parameter, there will be more than one value into that parameter, param_value varchar2(30)and param_name varchar2(4000).
    But I know nothing about what are the values may be in , when I execute the package...
    ALSO I AM ATTACHING SOME MORE DETAILS....
    create or replace package
    FUNCTION Main(p_env IN WB_RT_MAPAUDIT.WB_RT_NAME_VALUES) RETURN NUMBER IS
    end package
    In this main function, the p_env is getting Initialize, it calls the initialize
    procedure, there directly getting count on this parameter.
    my question is at what point of time these valiables get initialize and what
    are the exact details for the followings
    TYPE WB_RT_NAME_VALUE IS RECORD
    param_name varchar2(30),
    param_value varchar2(4000)
    TYPE WB_RT_NAME_VALUES IS TABLE OF
    WB_RT_NAME_VALUE
    INDEX BY BINARY_INTEGER;
    What are these two variables (param_name and param_value) implies in wb_rt_mapaudit package
    ANY HELP GREATLY APPRECIATED
    THANKS FOR YOUR TIME
    Gladson
    [email protected]

    Gladson,
    Page 8-73 of the Warehouse Builder user's guide explicitly highlights the following section:
    Note: Taking advantage of the Name and Address operator requires separate licensing and additional installation steps. Refer to the Oracle9i Warehouse Builder Installation and Configuration Guide for more information.
    The functionality that does the parsing and standardization is not part of Warehouse Builder, but part of the package that the software partner brings in. If you think about that, it actually makes sense. Would you expect Warehouse Builder to contain the code to perform this action for all countries across the globe, in all different languages and the like? The data vendors, who are the experts in the different areas, know this information.
    So, if all you want to do, is parse and standardize an address, then yes, you may be better of going directly to a partner (having said that, you may get a discount if you are a Warehouse Builder customer, but that I do not know for sure).
    However, what does Warehouse Builder add:
    - Data object design (maybe your target tables don't exist) and deployment
    - ETL design and code generation
    - Process flow creation and deployment
    - Execution management (automatic logging etc)
    - Integration with Discoverer
    - Metadata management, such as impact analysis, version management, multi language support...
    - Much, much more.
    Specific to name and address (or say data quality): if you include the name and address operator on a Warehouse Builder mapping, then you can plug in any partner library you want, and in case you find out that another partner delivers better results, then go with the other partner. At the end of the day, you abstracted the implementation from the design. That makes you much more flexible in your choice of a data vendor. Besides, you get impact analysis, lineage and lots of other metadata management features for free. On top of that, if you want to identify duplicates, perform householding and the like, then there is match and merge (which yes, is part of the tool and not a third-party implementation) in order to define the rules for matching and merging.
    Again, if you don't need any of that, then perhaps you don't want the overhead of having all this and you go directly to a data vendor.
    Hope this helps,
    Mark.

  • Need to perform both Queue and stack operations in Visual C# code

    Need to perform both Queue and stack operations, is any Data Structure available for this. or how can i custom create the structure for this?

    Hi,
    In this structure contains base logics of Queue and Stack. Well stack plays major role here with operations of PUSH, POP with additional operation of Queue i.e., ENQUEUE and DEQUEUE.  Here the stack has enqueue and dequeue 
    https://code.msdn.microsoft.com/The-Stacked-Queues-An-11f3703a
    Regards,
    Selva Ganapathy K

  • Sessions/connections gets hang during update and select operations.

    A table with 3 million records, which has customer details data.
    Everyday application is executing select and update queries on that table.
    Sessions/connections gets hang during update and select operations.
    After checking ADDM report, following are the findings:
    Please suggest the solutions
    Findings and Recommendations
    Finding 1: Row Lock Waits
    Impact is 145.22 active sessions, 99.77% of total activity.
    SQL statements were found waiting for row lock waits.
    Recommendation 1: Application Analysis
    Estimated benefit is 145.22 active sessions, 99.77% of total activity.
    Action
    Significant row contention was detected in the TABLE
    "AVAYA.AIRTEL_CUSTOMER_MASTER" with object ID 82155. Trace the cause of
    row contention in the application logic using the given blocked SQL.
    Related Object
    Database object with ID 82155.
    Rationale
    The SQL statement with SQL_ID "974vg65j29pmv" was blocked on row locks.
    Related Object
    SQL statement with SQL_ID 974vg65j29pmv.
    UPDATE AVAYA.AIRTEL_CUSTOMER_MASTER SET PREFERRED_LANGUAGE = :1
    WHERE ( AIRTEL_CUSTOMER_MASTER.MSISDN = :2 )
    Rationale
    The session with ID 50 and serial number 34525 in instance number 1 was
    the blocking session responsible for 100% of this recommendation's
    benefit.
    Symptoms That Led to the Finding:
    Wait class "Application" was consuming significant database time.
    Impact is 145.22 active sessions, 99.77% of total activity.
    Finding 2: Top SQL Statements
    Impact is 46.39 active sessions, 31.87% of total activity.
    SQL statements consuming significant database time were found. These
    statements offer a good opportunity for performance improvement.
    Recommendation 1: SQL Tuning
    Estimated benefit is 46.39 active sessions, 31.87% of total activity.
    Action
    Investigate the UPDATE statement with SQL_ID "974vg65j29pmv" for
    possible performance improvements. You can supplement the information
    given here with an ASH report for this SQL_ID.
    Related Object
    SQL statement with SQL_ID 974vg65j29pmv.
    UPDATE AVAYA.AIRTEL_CUSTOMER_MASTER SET PREFERRED_LANGUAGE = :1
    WHERE ( AIRTEL_CUSTOMER_MASTER.MSISDN = :2 )
    Rationale
    The SQL spent only 0% of its database time on CPU, I/O and Cluster
    waits. Therefore, the SQL Tuning Advisor is not applicable in this case.
    Look at performance data for the SQL to find potential improvements.
    Rationale
    Database time for this SQL was divided as follows: 100% for SQL
    execution, 0% for parsing, 0% for PL/SQL execution and 0% for Java
    execution.
    Rationale
    SQL statement with SQL_ID "974vg65j29pmv" was executed 212 times and had
    an average elapsed time of 2494 seconds.
    Rationale
    Waiting for event "enq: TX - row lock contention" in wait class
    "Application" accounted for 100% of the database time spent in
    processing the SQL statement with SQL_ID "974vg65j29pmv".

    **addm report **
              ADDM Report for Task 'TASK_7526'
    Analysis Period
    AWR snapshot range from 5003 to 5004.
    Time period starts at 08-JUL-13 11.00.27 AM
    Time period ends at 08-JUL-13 12.00.45 PM
    Analysis Target
    Database 'AVAYADB' with DB ID 2878789264.
    Database version 11.2.0.1.0.
    ADDM performed an analysis of instance avayadb, numbered 1 and hosted at
    NG-LA04AVAYA01.
    Activity During the Analysis Period
    Total database time was 563062 seconds.
    The average number of active sessions was 155.63.
    Summary of Findings
       Description         Active Sessions      Recommendations
                           Percent of Activity
    1  Row Lock Waits      155.44 | 99.88       1
    2  Top SQL Statements  26.67 | 17.14        1
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              Findings and Recommendations
    Finding 1: Row Lock Waits
    Impact is 155.4 active sessions, 99.88% of total activity.
    SQL statements were found waiting for row lock waits.
       Recommendation 1: Application Analysis
       Estimated benefit is 155.44 active sessions, 99.88% of total activity.
       Action
          Significant row contention was detected in the TABLE
          "AVAYA.AIRTEL_CUSTOMER_MASTER" with object ID 82155. Trace the cause of
          row contention in the application logic using the given blocked SQL.
          Related Object
             Database object with ID 82155.
       Rationale
          The SQL statement with SQL_ID "974vg65j29pmv" was blocked on row locks.
          Related Object
             SQL statement with SQL_ID 974vg65j29pmv.
             UPDATE AVAYA.AIRTEL_CUSTOMER_MASTER SET PREFERRED_LANGUAGE = :1
             WHERE  ( AIRTEL_CUSTOMER_MASTER.MSISDN = :2 )
       Rationale
          The session with ID 167 and serial number 6084 in instance number 1 was
          the blocking session responsible for 100% of this recommendation's
          benefit.
       Symptoms That Led to the Finding:
          Wait class "Application" was consuming significant database time.
          Impact is 155.45 active sessions, 99.88% of total activity.
    Finding 2: Top SQL Statements
    Impact is 26.66 active sessions, 17.14% of total activity.
    SQL statements consuming significant database time were found. These
    statements offer a good opportunity for performance improvement.
       Recommendation 1: SQL Tuning
       Estimated benefit is 26.67 active sessions, 17.14% of total activity.
       Action
          Investigate the UPDATE statement with SQL_ID "974vg65j29pmv" for
          possible performance improvements. You can supplement the information
          given here with an ASH report for this SQL_ID.
          Related Object
             SQL statement with SQL_ID 974vg65j29pmv.
             UPDATE AVAYA.AIRTEL_CUSTOMER_MASTER SET PREFERRED_LANGUAGE = :1
             WHERE  ( AIRTEL_CUSTOMER_MASTER.MSISDN = :2 )
       Rationale
          The SQL spent only 0% of its database time on CPU, I/O and Cluster
          waits. Therefore, the SQL Tuning Advisor is not applicable in this case.
          Look at performance data for the SQL to find potential improvements.
       Rationale
          Database time for this SQL was divided as follows: 100% for SQL
          execution, 0% for parsing, 0% for PL/SQL execution and 0% for Java
          execution.
       Rationale
          SQL statement with SQL_ID "974vg65j29pmv" was executed 707 times and had
          an average elapsed time of 794 seconds.
       Rationale
          Waiting for event "enq: TX - row lock contention" in wait class
          "Application" accounted for 100% of the database time spent in
          processing the SQL statement with SQL_ID "974vg65j29pmv".
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              Additional Information
    Miscellaneous Information
    Wait class "Commit" was not consuming significant database time.
    Wait class "Concurrency" was not consuming significant database time.
    Wait class "Configuration" was not consuming significant database time.
    Wait class "Network" was not consuming significant database time.
    Wait class "User I/O" was not consuming significant database time.
    Session connect and disconnect calls were not consuming significant database
    time.
    Hard parsing of SQL statements was not consuming significant database time.

  • My MacBook Pro won't load any websites on Safari (except this site, Facebook and Google), Opera, or Mozilla Firefox. I already did the "Reset Safari", restarted the computer half a dozen times, and I can't find this alleged "caches.db" file to delete.

    My MacBook Pro won't load any websites on Safari (except this site, Facebook and Google). Opera and Mozilla Firefox won't load any sites whatsoever. I already did the "Reset Safari" several times, restarted the computer half a dozen times, and I can't find this alleged "caches.db" file to delete. I virus scanned the computer with Sophos, Avast, and iAntiVirus and it looks clean.

    Is iAntiVirus the best virus protection to use for a MacBook?
    The best anti-virus protection is your own common sense, and what you already bought and paid for with your Mac. Third party products such as "iAntiVirus" convey no additional benefit, and as you already determined are very capable of causing trouble.
    OS X already includes everything it needs to protect itself from viruses and malware. Keep it that way with software updates from Apple.
    A much better question is "how should I protect my Mac":
    Never install any product that claims to "speed up", "clean up", "optimize", or "accelerate" your Mac. Without exception, they will do the opposite.
    Never install pirated or "cracked" software, software obtained from dubious websites, or other questionable sources. Illegally obtained software is almost certain to contain malware.
    Don’t supply your password in response to a popup window requesting it, unless you know what it is and the reason your credentials are required.
    Don’t open email attachments from email addresses that you do not recognize, or click links contained in an email:
    Most of these are scams that direct you to fraudulent sites that attempt to convince you to disclose personal information.
    Such "phishing" attempts are the 21st century equivalent of a social exploit that has existed since the dawn of civilization. Don’t fall for it.
    Apple will never ask you to reveal personal information in an email. If you receive an unexpected email from Apple saying your account will be closed unless you take immediate action, just ignore it. If your iTunes or App Store account becomes disabled for valid reasons, you will know when you try to buy something or log in to this support site, and are unable to.
    Don’t install browser extensions unless you understand their purpose. Go to the Safari menu > Preferences > Extensions. If you see any extensions that you do not recognize or understand, simply click the Uninstall button and they will be gone.
    Don’t install Java unless you are certain that you need it:
    Java, a non-Apple product, is a potential vector for malware. If you are required to use Java, be mindful of that possibility.
    Java can be disabled in System Preferences.
    Despite its name JavaScript is unrelated to Java. No malware can infect your Mac through JavaScript. It’s OK to leave it enabled.
    Block browser popups: Safari menu > Preferences > Security > and check "Block popup windows":
    Popup windows are useful and required for some websites, but popups have devolved to become a common means to deliver targeted advertising that you probably do not want.
    Popups themselves cannot infect your Mac, but many contain resource-hungry code that will slow down Internet browsing.
    If you ever see a popup indicating it detected registry errors, that your Mac is infected with some ick, or that you won some prize, it is 100% fraudulent. Ignore it.
    Ignore hyperventilating popular media outlets that thrive by promoting fear and discord with entertainment products arrogantly presented as "news". Learn what real threats actually exist and how to arm yourself against them:
    The most serious threat to your data security is phishing. To date, most of these attempts have been pathetic and are easily recognized, but that is likely to change in the future as criminals become more clever.
    OS X viruses do not exist, but intentionally malicious or poorly written code, created by either nefarious or inept individuals, is nothing new.
    Never install something without first knowing what it is, what it does, how it works, and how to get rid of it when you don’t want it any more.
    If you elect to use "anti-virus" software, familiarize yourself with its limitations and potential to cause adverse effects, and apply the principle immediately preceding this one.
    Most such utilities will only slow down and destabilize your Mac while they look for viruses that do not exist, conveying no benefit whatsoever - other than to make you "feel good" about security, when you should actually be exercising sound judgment, derived from accurate knowledge, based on verifiable facts.
    Do install updates from Apple as they become available. No one knows more about Macs and how to protect them than the company that builds them.
    Summary: Use common sense and caution when you use your Mac, just like you would in any social context. There is no product, utility, or magic talisman that can protect you from all the evils of mankind.

  • Help with binary to decimal, binary to hex, and hex to ascii or ascii to hex program

    I decided to do a program that will do binary to decimal, binary to hex, and hex to ascii for a project related to a java programming course, which only needs to perform features from chapters 1-6 and 8 of Tony Gaddis's book. The functions work fine as their own main programs out side of this combined effort, so can anyone help me determine why I get the following 41 errrors saying: class, interface, or enum expected as well as any other errors that may show up afterwards because I'm stumped. My flowcharts, which have to be revised after discovering that my previous function were logically incorrect after running them in their own main are attached below as the spec sheet.
    My code is as follows and I hope you don't mind the commented lines of unused code because I'm not sure where I want things and what I want at the moment:
    import java.util.Scanner;
    import java.io.*;
    import java.lang.*;
    public class BintoDectoHextoAscii
       public static void main(String[] args)throws IOException
          Scanner input = new Scanner(System.in);
          System.out.println("Enter a binary number: ");
          String binary = input.nextLine(); // store input from user
         if (binary == input.nextLine())
          //int i= Integer.parseInt(hex,2);
          //String hexString = Integer.toHexString(i);
          //System.out.println("Hexa decimal: " + hexString);
          //int finaldecimalvalue = binaryToDecimal(hexString);
          int finaldecimalvalue = binaryToDecimal(hexString);
         if (binary != input.nextLine())
          String hexInput; // The variable Bin Input declared as the datatype int to store the Binary value  
          // Create a Scanner object for keyboard input.
          //Scanner keyboard = new Scanner(System.in);
          // Get the number of binary files.
          System.out.print("Enter the Hex value: ");
          hexInput = keyboard.nextLine();
          System.out.println("Original String: "+ hexInput);
          //String hexEquivalent = asciiToHex(demoString);
          String hexEquivalent = asciiToHex(hexInput);
          //Hex value of original String
          System.out.println("Hex String: "+ hexEquivalent);
          String asciiEquivalent = hexToASCII(hexEquivalent);
          //ASCII value obtained from Hex value
          System.out.println("Ascii String: "+ asciiEquivalent);String finalhexOutput = HextoAsciiConverter(hexEquivalent);
         if (binary != input.nextLine() && hexInput != keyboard.nextLine())
             BufferedReader binInput = new BufferedReader(new InputStreamReader(System.in));
             System.out.println("Enter the Binary number:");
             String hex = binInput.readLine();
             //String finaldecimalvalue = binaryToDecimal(decimal);
             //long finalhexvalue = BinaryToHexadecimal(num);
             long finalhexvalue = BinaryToHexadecimal();
       public static String BinaryToHexadecimal(String hex)
          //public static void main(String[] args)throws IOException
             //BufferedReader bf= new BufferedReader(new InputStreamReader(System.in));
             //System.out.println("Enter the Binary number:");
             //String hex = binInput.readLine();
             long num = Long.parseLong(hex);
             long rem;
             while(num > 0)
             rem = num % 10;
             num = num / 10;
             if(rem != 0 && rem != 1)
             System.out.println("This is not a binary number.");
             System.out.println("Please try once again.");
             System.exit(0);
             int i= Integer.parseInt(hex,2);
             String hexString = Integer.toHexString(i);
             System.out.println("Hexa decimal: " + hexString);
          return num.tolong();
      //int i= Integer.parseInt(hex,2);
      //String hexString = Integer.toHexString(i);
      //System.out.println("Hexa decimal: " + hexString);
    //} // end BintoDectoHextoAsciil
       //public static String HexAsciiConverter(String hextInput)
          // Get the number of binary files.
          //System.out.print("Enter the Hex value: ");
          //hexInput = keyboard.nextLine();
          //System.out.println("Original String: "+ hexInput);
          //String hexEquivalent = asciiToHex(demoString);
          //String hexEquivalent = asciiToHex(hexInput);
          //Hex value of original String
          //System.out.println("Hex String: "+ hexEquivalent);
          //String asciiEquivalent = hexToASCII(hexEquivalent);
          //ASCII value obtained from Hex value
          //System.out.println("Ascii String: "+ asciiEquivalent);
       //} // End function  
       private static String asciiToHex(String asciiValue)
          char[] chars = asciiValue.toCharArray();
          StringBuffer hex = new StringBuffer();
          for (int i = 0; i < chars.length; i++)
             hex.append(Integer.toHexString((int) chars[i]));
          return hex.toString();
       private static String hexToASCII(String hexValue)
          StringBuilder output = new StringBuilder("");
          for (int i = 0; i < hexValue.length(); i += 2)
             String str = hexValue.substring(i, i + 2);
             output.append((char) Integer.parseInt(str, 16));
          return output.toString();
       public static String binaryToDecimal(String binary)
            //Scanner input = new Scanner(System.in);
            //System.out.println("Enter a binary number: ");
            //String binary = input.nextLine(); // store input from user
            int[] powers = new int[16]; // contains powers of 2
            int powersIndex = 0; // keep track of the index
            int decimal = 0; // will contain decimals
            boolean isCorrect = true; // flag if incorrect input
           // populate the powers array with powers of 2
            for(int i = 0; i < powers.length; i++)
                powers[i] = (int) Math.pow(2, i);
            for(int i = binary.length() - 1; i >= 0; i--)
                // if 1 add to decimal to calculate
                if(binary.charAt(i) == '1')
                    decimal = decimal + powers[powersIndex]; // calc the decimal
                else if(binary.charAt(i) != '0' & binary.charAt(i) != '1')
                    isCorrect = false; // flag the wrong input
                    break; // break from loop due to wrong input
                } // end else if
                // keeps track of which power we are on
                powersIndex++; // counts from zero up to combat the loop counting down to zero
            } // end for
            if(isCorrect) // print decimal output
                System.out.println(binary + " converted to base 10 is: " + decimal);
            else // print incorrect input message
                System.out.println("Wrong input! It is binary... 0 and 1's like.....!");
            return decimal.toint();
       } // end function
    The errors are as follows:
    ----jGRASP exec: javac BintoDectoHextoAscii.java
    BintoDectoHextoAscii.java:65: error: class, interface, or enum expected
       public static String BinaryToHexadecimal(String hex)
                     ^
    BintoDectoHextoAscii.java:73: error: class, interface, or enum expected
             long rem;
             ^
    BintoDectoHextoAscii.java:74: error: class, interface, or enum expected
             while(num > 0)
             ^
    BintoDectoHextoAscii.java:77: error: class, interface, or enum expected
             num = num / 10;
             ^
    BintoDectoHextoAscii.java:78: error: class, interface, or enum expected
             if(rem != 0 && rem != 1)
             ^
    BintoDectoHextoAscii.java:81: error: class, interface, or enum expected
             System.out.println("Please try once again.");
             ^
    BintoDectoHextoAscii.java:83: error: class, interface, or enum expected
             System.exit(0);
             ^
    BintoDectoHextoAscii.java:84: error: class, interface, or enum expected
             ^
    BintoDectoHextoAscii.java:87: error: class, interface, or enum expected
             String hexString = Integer.toHexString(i);
             ^
    BintoDectoHextoAscii.java:88: error: class, interface, or enum expected
             System.out.println("Hexa decimal: " + hexString);
             ^
    BintoDectoHextoAscii.java:90: error: class, interface, or enum expected
          return num.tolong();
          ^
    BintoDectoHextoAscii.java:91: error: class, interface, or enum expected
       ^
    BintoDectoHextoAscii.java:124: error: class, interface, or enum expected
          StringBuffer hex = new StringBuffer();
          ^
    BintoDectoHextoAscii.java:125: error: class, interface, or enum expected
          for (int i = 0; i < chars.length; i++)
          ^
    BintoDectoHextoAscii.java:125: error: class, interface, or enum expected
          for (int i = 0; i < chars.length; i++)
                          ^
    BintoDectoHextoAscii.java:125: error: class, interface, or enum expected
          for (int i = 0; i < chars.length; i++)
                                            ^
    BintoDectoHextoAscii.java:128: error: class, interface, or enum expected
          ^
    BintoDectoHextoAscii.java:130: error: class, interface, or enum expected
       ^
    BintoDectoHextoAscii.java:135: error: class, interface, or enum expected
          for (int i = 0; i < hexValue.length(); i += 2)
          ^
    BintoDectoHextoAscii.java:135: error: class, interface, or enum expected
          for (int i = 0; i < hexValue.length(); i += 2)
                          ^
    BintoDectoHextoAscii.java:135: error: class, interface, or enum expected
          for (int i = 0; i < hexValue.length(); i += 2)
                                                 ^
    BintoDectoHextoAscii.java:138: error: class, interface, or enum expected
             output.append((char) Integer.parseInt(str, 16));
             ^
    BintoDectoHextoAscii.java:139: error: class, interface, or enum expected
          ^
    BintoDectoHextoAscii.java:141: error: class, interface, or enum expected
       ^
    BintoDectoHextoAscii.java:144: error: class, interface, or enum expected
       public static String binaryToDecimal(String binary)
                     ^
    BintoDectoHextoAscii.java:150: error: class, interface, or enum expected
            int powersIndex = 0; // keep track of the index
            ^
    BintoDectoHextoAscii.java:151: error: class, interface, or enum expected
            int decimal = 0; // will contain decimals
            ^
    BintoDectoHextoAscii.java:152: error: class, interface, or enum expected
            boolean isCorrect = true; // flag if incorrect input
            ^
    BintoDectoHextoAscii.java:155: error: class, interface, or enum expected
            for(int i = 0; i < powers.length; i++)
            ^
    BintoDectoHextoAscii.java:155: error: class, interface, or enum expected
            for(int i = 0; i < powers.length; i++)
                           ^
    BintoDectoHextoAscii.java:155: error: class, interface, or enum expected
            for(int i = 0; i < powers.length; i++)
                                              ^
    BintoDectoHextoAscii.java:159: error: class, interface, or enum expected
            for(int i = binary.length() - 1; i >= 0; i--)
            ^
    BintoDectoHextoAscii.java:159: error: class, interface, or enum expected
            for(int i = binary.length() - 1; i >= 0; i--)
                                             ^
    BintoDectoHextoAscii.java:159: error: class, interface, or enum expected
            for(int i = binary.length() - 1; i >= 0; i--)
                                                     ^
    BintoDectoHextoAscii.java:166: error: class, interface, or enum expected
                else if(binary.charAt(i) != '0' & binary.charAt(i) != '1')
                ^
    BintoDectoHextoAscii.java:169: error: class, interface, or enum expected
                    break; // break from loop due to wrong input
                    ^
    BintoDectoHextoAscii.java:170: error: class, interface, or enum expected
                } // end else if
                ^
    BintoDectoHextoAscii.java:174: error: class, interface, or enum expected
            } // end for
            ^
    BintoDectoHextoAscii.java:180: error: class, interface, or enum expected
            else // print incorrect input message
            ^
    BintoDectoHextoAscii.java:185: error: class, interface, or enum expected
            return decimal.toint();
            ^
    BintoDectoHextoAscii.java:186: error: class, interface, or enum expected
       } // end function
       ^
    41 errors
    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.

    so can anyone help me determine why I get the following 41 errrors saying: class, interface, or enum expected as well as any other errors that may show up afterwards because I'm stumped.
    Yes - YOU CAN!
    My code is as follows and I hope you don't mind the commented lines of unused code because I'm not sure where I want things and what I want at the moment:
    Excellent! Commenting out code is EXACTLY how you troubleshoot problems like yours.
    Comment out sections of code until the problem goes away. Then start adding back ONE SECTION of code at a time until the problem occurs. When it does you have just FOUND the problem.
    If you do that you wind up with code that looks like this:
    import java.util.Scanner;
    import java.io.*;
    import java.lang.*;
    public class BintoDectoHextoAscii  {
          public static void main(String[] args)throws IOException      {
             Scanner input = new Scanner(System.in);
             System.out.println("Enter a binary number: ");
             String binary = input.nextLine(); // store input from user
                  public static String BinaryToHexadecimal(String hex)     {     } // end function        
    Notice ANYTHING UNUSUAL?
    You have a complete CLASS definition followed by a method definition.
    Methods have to be INSIDE the class - you can NOT define methods on their own.
    Write modular code.
    Write EMPTY methods - just the method signature and maybe a RETURN NULL if you need to return something.
    Then add calls to those empty methods.
    When everything compiles and runs find you can start adding code to the methods ONE METHOD AT A TIME.
    Test compile and run after you add the code for each method.

  • Invalid operands to binary ^ (have 'double' and 'double')

    Hi all,
    I've been trying to make some calculus like
    double a, b, c;
    b = 0.3;
    c =0.35;
    a = b^c;
    but I get this error message: *"Invalid operands to binary ^ (have 'double' and 'double')"*. Does anybody know how to solve this?
    Thanks in advance!

    Yes I think Ray hit the nail on the head. It looks as if you wanted to perform and exponentiation operation, not a bitwise operation. So, just to expand on Ray's answer a bit, the carrot symbol (^) that you used in your statement is, in C, the bitwise XOR operator, and has nothing to do with exponentiation. There are numerous bitwise operators in C (bitwise AND (&), bitwise OR (|), bitwise XOR (^)), and they all deal with manipulating bits of data. If you were, in fact, trying to raising b to the power of c and assign that value back to a, then Ray's post was the perfect answer as to how to do that.
    Many programmers that are new to C, especially ones coming from a language such as Visual Basic, where the carrot symbol is used for exponentiation operations, naturally try to use the same symbol for the same purpose in C, and are surprised to find that it doesn't do what they expected (understandably). As mentioned, this is because, in C, there is no exponentiation operator, and the carrot symbol does something completely different and unrelated to exponentiation. However, C does provide a predefined function in its standard library for exponentiation, and it is called the pow() function, which takes two double-typed arguments (the first is the number being risen and the second is the power that it is being raised to), and returns the result as a double. To use this function, all you have to do is write an include directive at the top of the file that you will be using the function in that tells the preprocessor to include the file math.h. See RayNewb's post for a solid example of how all this stuff would look in your source code, and, as he mentioned, open your Terminal and type in +man math+ or, for this particular function, +man pow+ to find out more about how this function works (you can page through the information with the spacebar or scroll down with the down arrow).
    Hope this was of some help for you, and best of luck with everything!

  • REJECT_CODE Vendor information and/or Operating Unit information is missing

    hi
    i am using Oracle Applications : 11.5.10.2.
    i am trying to load suppliers and suppliers data into oracle AP.
    i tried doing this with some sample data.
    i executed the following code below :
    insert into AP_SUPPLIERS_INT (VENDOR_INTERFACE_ID, VENDOR_NAME, SEGMENT1, STATUS)
    values (*10006*,'XXX Financials2','199999','NEW');
    i then ran the following process:
    Supplier Open Interface Import
    the supplier was added without errors
    i then inserted a record into the
    AP_SUPPLIER_SITES_INT table :
    vendor_interface_id =*10006*,
    LAST_UPDATE_DATE= SYSDATE,
    LAST_UPDATED_BY          ='123',
    VENDOR_SITE_CODE = 'true test' ,
    CREATION_DATE     =SYSDATE ,
    CREATED_BY     ='123' ,
    PURCHASING_SITE_FLAG= 'N' ,
    PAY_SITE_FLAG     = 'Y' ,
    ATTENTION_AR_FLAG     = 'N' ,
    ADDRESS_LINE1     ='gmmm df' ,
    ADDRESS_LINE2     ='gmmm dfdv' ,
    ADDRESS_LINE3     ='gmmm dfvdd' ,
    ADDRESS_LINE4     ='gmmm dfvdd' ,
    PAYMENT_METHOD_LOOKUP_CODE='Check' ,
    TERMS_DATE_BASIS     ='Current' ,
    ACCTS_PAY_CODE_COMBINATION_ID     = '1365' ,
    PREPAY_CODE_COMBINATION_ID     = '1470' ,
    PAYMENT_PRIORITY     = '99' ,
    TERMS_ID= '10001' ,
    INVOICE_AMOUNT_LIMIT =20,          
    PAY_DATE_BASIS_LOOKUP_CODE     = 'DISCOUNT' ,
    ALWAYS_TAKE_DISC_FLAG= 'A' ,
    INVOICE_CURRENCY_CODE     ='JMD' ,
    PAYMENT_CURRENCY_CODE     ='JMD' ,
    HOLD_ALL_PAYMENTS_FLAG='N' ,
    HOLD_FUTURE_PAYMENTS_FLAG     ='N' ,
    HOLD_UNMATCHED_INVOICES_FLAG= 'N' ,
    EXCLUSIVE_PAYMENT_FLAG= 'N' ,
    EXCLUDE_FREIGHT_FROM_DISCOUNT     = 'N' ,
    ORG_ID= '142' ,
    CREATE_DEBIT_MEMO_FLAG= 'N' ,
    OFFSET_TAX_FLAG= 'N'
    i then ran the following process:
    Supplier Sites Open Interface Import
    the process completes with a status of 'Normal'.
    below is an extract of the output :
    Supplier Sites Open Interface Import Execution Repor Page: 1
    Import Options: All
    Batch Size: 1000
    Print Exceptions Only: No
    Sites Open Interface Audit Report
    Org Id Supplier Number Supplier Name Site Name
    Total Sites Imported: 0
    *** No Data Exists for this Report ***
    Sites Open Interface Rejections Report
    Org Id Supplier Number Supplier Name Site Name Reason
    Total Sites Rejected: 0
    when i checked the AP_SUPPLIER_SITES_INT table ,
    the REJECT_CODE field has the value *'Vendor information and/or Operating Unit information is missing.'*
    I THINK ALL THE REQUIRED FIELDS ARE POPULATED
    why am i recieving this error ? is this caused by a bug? is there a required field that i didn't populated ?
    please help me to solve this ....
    thanks much!!

    Hi,
    Could you please check : Doc ID: 316368.1 of Metalink...
    Symptoms_+
    The Supplier Site Contacts Open Interface Import program is not importing certain contact
    information.
    The Supplier Site Contacts Open Interface Import Execution Report shows the following Rejection
    Reason:
    Vendor information and/or Operating Unit information is missing
    Cause_+
    The Last_name field is a required field.
    As per the Oracle Payables User's Guide.
    Appendix G-111
    AP_SUP_SITE_CONTACT_INT chart shows the LAST_NAME is a Required field
    Solution_+
    As per the Oracle Payables User's Guide.
    Appendix G-111
    AP_SUP_SITE_CONTACT_INT chart shows the LAST_NAME is a Required field
    If you test this out directly in the Suppliers window in Oracle Payables:
    Navigation: Suppliers-Entry
    Queried up a Supplier, then clicked into the Site field under the Contact tab.
    Entered the contact information and omitted the Last Name, when trying to save the record,
    the system gives the following message:
    *'FRM-40202: Field must be entered' and the cursor is on the Last Name field. This is a required*
    field and is the intended functionality.
    Hope this will help
    Regards,
    S.P DASH

  • Vendor information and/or Operating Unit information is missing.

    Hi,
    I am new to the interface and learning programing can any body pls help me on this accept i will be thank full
    I am running AP_SUPPLIER_SITES_INT and i got an error as
    Vendor information and/or Operating Unit information is missing.
    and also pls give me the diff b/w org_id and operating unit why the tables end with _all.
    Thanks in advance
    Thanks and regards
    Goutham
    Message was edited by:
    goutham konduru

    check out these:
    http://www.oracleappshub.com/oracle-application/_all-tl-vl-vf_vl_a_avn-and-what-else/
    http://www.oracleappshub.com/beginner/understanding-multi-organization-structure-in-ebs-part-1/

  • How to erase all data on macbook pro and reinstall operating system

    how to erase all data on macbook pro and reinstall operating system

    OS X Snow Leopard
    https://support.apple.com/en-us/HT3910
    http://www.thesafemac.com/how-to-reinstall-mac-os-x-from-scratch/
    OS X Yosemite
    https://support.apple.com/kb/PH18869?locale=en_US&viewlocale=en_US
    Best.

  • Hello! I would like to know about unlock my iphone 4? IMEI *** Serial number 87******A4T And what operator it is locked?

    Hello! I would like to know about unlock my iphone 4? IMEI **** Serial number 87******A4T And what operator it is locked?
    <Edited By Host>

    I don't know if they have email but you can start here  http://www.apple.com/support/contact/

  • When restoring an iPhoto library I got an "unexpected error" message and the operation could not be completed. Is my best choice to try again?

    One of my external hard drives died. I had several iPhoto libraries in it. Fortunately, I used Time Machine to backup to a Time Capsule and I can see all the iPhoto library icons in Backups.
    When restoring the first iPhoto library, after three hours, I got an "unexpected error" message and the operation could not be completed. Indeed, the restored library is smaller than the library in Backups. Is my best choice to try again and replace the restored library (which apparently must be missing some photos)? It would mean another 3 hours plus of restoration with fingers crossed...
    Any suggestions? Thank you in advance!

    I am always suspicious of using a different OS to the one that was used to run the backup.. ie if you used Snow L to backup then there is absolutely nothing wrong with using SL to restore.
    Mount the TC sparsebundle and verify it using disk utility.
    A5 here. http://pondini.org/TM/Troubleshooting.html
    You might also like to load the widget in Time Machine so you get whatever the full error message is..
    I cannot find any reference to the error code you are getting..
    My recommendation would be to try it on a different computer.. restore the whole backup to an external drive large enough to accept the whole backup.
    Use the manual methods pondini recommends.
    http://pondini.org/TM/FAQ.html
    Q16 17
    Use ethernet only. Turn off wireless so it does not enter the situation.

Maybe you are looking for

  • When I click on a picture to enlarge - on many websites - I just get a blank screen. Please help. AJB

    When i left click on a picture to enlarge on many websites - I just get a blank screen. when I centre click on that same picture it gives me an (untitled) - in the tab and the following (as an example) in the top bar javascript:openScreenWin('smallsc

  • I can't delete songs off of my iPhone while in the "On this iPhone" tab in iTunes?

    Well what I'd like to be able to do is to delete songs while in the "on this iPhone" tab. It's the one that allows you to add songs straight to your phone without going through the trouble of syncing or selecting playlists and all that. I believe it

  • Accrual process in SAP.

    Dear All, Could you please tell me how to make an invoice in SAP but the Account Receivable is only 95% from total sales (the remaining 5% is as accrual). Example :- A service job amounting INR 1 000 000 has completed in December 2008. Referring to c

  • SharePoint templates and metadata

    Hello,     Is there a way to have connection among the sharepoint metadata -columns and some keywords contained on the template? On other words, i need that the users create a document based on a template at a document library, enter data on the temp

  • Account Generator, and AME

    Hi, 2 questions- 1.Is it possible to use more than one account generator process for a particular accounting flexfield structure? I have attached the process 'Generate Default Accounts' to the item type 'PO Requisition Account Generator', however is