|
|||||||
| Notices |
| Off Topic Discussions Anything that's not category related can go here. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Apr 2009
Posts: 8
![]() |
Hello great folks of this great site,
As some of you know, I've been very busy studying networking and java. I have a serious question in java that's been bugging me all month: What is the discriminant? Can any one gives me a clear, down to earth definition of what this type is and how/when would I use it in a program? the example code I have is below: Code:
double b = Double.parseDouble(args[0]); double c = Double.parseDouble(args[1]); double discriminant = b*b - 4.0*c; double d = Math.sqrt(discriminant); However, why couldn't they just use another double type variable at line 3 instead of discriminant? wouldn't any other variable do the same operations of (b*b - 4.0*c)? Thanks in advanced and happy new year to all ![]() Last edited by wimiadmin; 12-28-2009 at 07:12 PM. |
|
|
|
|
#2 |
|
Super Moderator
|
Here's an explanation of the term "discriminant" which I obtained from a google search of "discriminant quadratic". (I haven't read this - however it looks OK).
http://www.mathwords.com/d/discriminant_quadratic.htm The java code: Code:
double discriminant = b*b - 4.0*c; double d = Math.sqrt(discriminant); Code:
double cheeseburgerwithfriesandashake = b*b - 4.0*c; double d = Math.sqrt(cheeseburgerwithfriesandashake); I assume that you inherited this code from a programmer who (rightly) believes that the variable name "discriminant" is more meaningful than "cheeseburgerwithfriesandashake". Of course it could be written as: Code:
double d = Math.sqrt(b*b - 4.0*c); Of course you can modify the java 'bomb' experience with try ... catch ... however that's another matter about which you'll have to learn. Happy New Year to you. Best Wishes for 2010. Robin Last edited by clanmills; 12-29-2009 at 04:46 AM. |
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|