Thursday, August 22, 2013

For Java Students....

Please post here any query related to Java. I don't say that I have all the answers, but I assure you that even if I don't have it I will find the one for you. I hope that will work.

4 comments:

  1. not able to access 3rd teem notes ie java+asp+javascript+css
    sir i am 3rd year student from amity and i ned to access this topic
    so kindly restore the document or give me permission to access it

    ReplyDelete
  2. please try to access it again as I have kept it in the public domain, i.e. no login required to access that... If it don't work again, Please mail me I will email you the direct copy.

    ReplyDelete
  3. Why is the output 0.89999 instead of 0.9 ? In the following peogram.

    class Ideone
    {
    public static void main (String[] args) throws java.lang.Exception
    {
    double x = 2.0;
    double y = 1.1;
    System.out.println( (x - y) );

    }
    }

    ReplyDelete
  4. It is because of the range of the double which it caries and its difference in bits assigned for exponent and mantissa w.r.t float, You are actually trying to access very short range values in the double format.

    Try the following programs to understand the things better:

    Program 1:
    public class HelloWorld{

    public static void main(String []args){
    float x = 2.0f;
    float y = 1.1f;
    System.out.println( (double)(x - y) );
    }
    }

    Output: 0.8999999761581421

    Program 2:

    public class HelloWorld{

    public static void main(String []args){

    double x = 2.0;
    double y = 1.1;
    System.out.println( (float)(x - y) );
    }
    }

    Output: 0.9

    ReplyDelete