Search:

Type: Posts; User: Zaphod_b

Search: Search took 0.32 seconds.

  1. Replies
    25
    Views
    2,780

    Re: Why so many decimal points in my basic code?

    I gave several examples. None was intended to be dropped directly into your program, since they used different variable names and various kinds of format that might not be what you are looking for....
  2. Replies
    25
    Views
    2,780

    Re: Why so many decimal points in my basic code?

    DecimalFormat and (NumberFormat) are in the java.text package, so at the beginning of your program, you can put the following statement to let Java know that's what you are going to use:

    import...
  3. Replies
    25
    Views
    2,780

    Re: Why so many decimal points in my basic code?

    As documented in the links that I gave in my first post:
    The static format method of the NumberFormat returns a String. The static format method of the DecimalFormat classes returns a String.
    ...
  4. Replies
    25
    Views
    2,780

    Re: Why so many decimal points in my basic code?

    That code will not compile, so I can't see how it could be giving a runtime exception. For best chances of getting helpful responses with fewest iterations it is recommended to post the exact code...
  5. Replies
    25
    Views
    2,780

    Re: Why so many decimal points in my basic code?

    Here's the thing: The author of Java made it "easy" to print out numerical values as long as you don't care what they look like. If you want to print floating point numbers formatted a certain way,...
Results 1 to 5 of 6