Results 1 to 6 of 6
- 07-17-2011, 12:16 PM #1
Member
- Join Date
- Jul 2011
- Location
- New Delhi,India
- Posts
- 56
- Rep Power
- 0
stuck at isInfinite and isNan....please help
public class InfNaN {
public static void main(String[] args) {
Double d1=new Double(1/0.);
Double d2=new Double(0/0.);
System.out.println("Infinite:"+d1.isInfinite()+"\n Not a number:"+d1.isNaN());
System.out.println("Infinite:"+d2.isInfinite()+"\n Not a number:"+d2.isNaN());
}
}
this is my program...i want to ask what is the use of .(dot) in Double class constructor(i.e.what it means by 1/0.???)
i wrote the program without using .(dot) and i got the exception of divide by zero.....
-
Without the dot you're working with ints, not doubles and doing int division, not double division, and as you're finding out, they behave differently.
- 07-17-2011, 12:22 PM #3
Member
- Join Date
- Jul 2011
- Location
- New Delhi,India
- Posts
- 56
- Rep Power
- 0
that means by double division we can divide a number by zero and we wont get divide by zero exception????
- 07-17-2011, 12:24 PM #4
Member
- Join Date
- Jul 2011
- Location
- New Delhi,India
- Posts
- 56
- Rep Power
- 0
thanks bro....i got my answer....
-
No need for us to tell you anything as you can see the results for yourself in your code's output. But if you want to learn more about this, check out what the Java Language Specification (JLS) has to say about this: JLS §15.17.2 Division Operator /
- 07-17-2011, 12:58 PM #6
Member
- Join Date
- Jul 2011
- Location
- New Delhi,India
- Posts
- 56
- Rep Power
- 0
Similar Threads
-
Really stuck need help
By B_Tank88 in forum New To JavaReplies: 45Last Post: 07-18-2011, 07:52 PM -
I'm stuck help!!!
By nobody58 in forum Advanced JavaReplies: 2Last Post: 03-18-2010, 02:52 PM -
Stuck in sea
By programmer_007 in forum JDBCReplies: 1Last Post: 09-17-2009, 04:00 AM -
Im on my last lab!!!! And im stuck...:(
By clanboru15 in forum New To JavaReplies: 5Last Post: 03-13-2009, 01:44 AM -
really stuck now..
By shongo in forum Advanced JavaReplies: 2Last Post: 11-09-2008, 02:56 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks