Search:

Type: Posts; User: Chris.Brown.SPE

Search: Search took 0.08 seconds.

  1. Replies
    5
    Views
    1,514

    Re: Java printf

    Example: Votes = 10 and Total = 56; Votes / Total = 0...But (Votes * 1.0) / (Total * 1.0) = 0.17857142857

    --- Update ---

    The 5.2 gives you 5 characters prior to decimal and 2 numbers precision...
  2. Replies
    5
    Views
    1,514

    Re: Java printf

    Exactly what i said. Those two values you are dividing are integers not floats so the %5.2f is upset because it is expecting a float.
  3. Replies
    5
    Views
    1,514

    Re: Java printf

    I'm guessing because i cant see the rest of your code. Is getVotes() and total ints or Integers? An int divided by an int is still an int. There will be no float value produced. An easy way to trick...
Results 1 to 3 of 3