English subtitles

← Average of No Inputs - Intro to Java Programming

Get Embed Code
5 Languages

Showing Revision 5 created 05/24/2016 by Udacity Robot.

  1. Lets try it out. Here is our average program. If we just enter q immediately
  2. then it tells us NaN but what does NaN mean? Lets ask everybody on the
  3. Internet. Lets search for java NaN. Looks like other people have had this
  4. question before and under the answers it says NaN stands for not a number. It's
  5. produced if some floating point operation has some input parameters that cause
  6. the operation to produce some undefined result. For example, 0 divided by 0 is
  7. arethmatically undefined. So we must have done some kind of math that was
  8. undefined. It seems like the most complicated piece of math we're doing here is
  9. just this division. So let's print out what sum and count are. Here's a print
  10. line statement from sum and count. And now, if I enter q immediately, it tells
  11. me that sum and count are both 0. So it makes sense that I'm getting NaN; I'm
  12. dividing by 0.