Results 1 to 2 of 2
  1. #1
    yaboty is offline Member
    Join Date
    Nov 2011
    Posts
    1
    Rep Power
    0

    Default possible lose of precision error

    hi guys
    first post on the forum , i hope anyone can help me
    i got this error of possible loss of precision whenever i compile this code


    public class assignment {

    public String encode(String s , int[] a , int []b){
    int length=a.length;
    QueueObj key1=new QueueObj(length);
    StackObj key2= new StackObj(length);
    for (int i=0 ; i<length; i++){
    key1.enqueue(a[i]);
    key2.push(b[length-i]);
    }
    QueueObj tempkey=new QueueObj(length);
    int slength=s.length();
    String result;
    int offset=0;
    int tempkey1=0;
    int tempkey2=0;
    int askii=0;
    for (int i=0; i<slength ; i++){
    tempkey1=0;
    tempkey2=0;
    askii=0;
    tempkey1=((Integer)key1.dequeue()).intValue();
    key1.enqueue(tempkey1);
    if (key2.size()==0){
    for (int j=0 ; j<length; j++){
    key2.push(tempkey.dequeue());
    }

    }
    tempkey2=((Integer)key2.pop()).intValue();
    offset=tempkey1+tempkey2;
    askii=s.charAt(i);
    askii=askii+offset;
    if(askii>122){
    int diff=122-askii;
    askii=97+diff;

    }
    char yarabne5las=askii;
    result=result+yarabne5las;
    }
    }

    }

    the error seems to be in the before last line of coding char yarabne5las=askii;

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: possible lose of precision error

    The variable askii has a type of int and yet you are trying to assign it to a char variable. You need to cast it as long as you are 100% sure what you are doing.

Similar Threads

  1. ERROR : possible loss of precision
    By subith86 in forum New To Java
    Replies: 1
    Last Post: 01-19-2011, 06:17 PM
  2. Precision
    By c_walker in forum New To Java
    Replies: 1
    Last Post: 10-18-2009, 12:36 PM
  3. how to let the shell window in SWT lose focus
    By kents in forum SWT / JFace
    Replies: 2
    Last Post: 06-25-2009, 11:34 AM
  4. help me- loss of precision error??
    By j2vdk in forum New To Java
    Replies: 6
    Last Post: 09-01-2008, 10:23 AM
  5. Radio button values are not lose
    By chockalingam in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-03-2007, 09:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •