Results 1 to 6 of 6
  1. #1
    Zelaine is offline Senior Member
    Join Date
    Aug 2013
    Location
    Sweden
    Posts
    152
    Rep Power
    2

    Default Rounding Numbers

    Is there a way to round double variables to a specified number of significant figures?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,941
    Rep Power
    8

    Default Re: Rounding Numbers

    Yes.

    What have you tried?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,914
    Rep Power
    5

    Default Re: Rounding Numbers

    Why do you ask? Yes is the answer to the question asked. If another answer was expected, another question should have been asked.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,540
    Rep Power
    5

    Default Re: Rounding Numbers

    Do you really want to round them or just display them with limited precision?

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  5. #5
    Zelaine is offline Senior Member
    Join Date
    Aug 2013
    Location
    Sweden
    Posts
    152
    Rep Power
    2

    Default Re: Rounding Numbers

    I have tried rounding doubles to integers but that was obviously not satisfactory :P I want to display them with limited precision, for example if I have the number 1 I want to be able to output more significant figures than necessary, like 1.00000, but also to round numbers like 1.75634234 to a specific significant figure, for example to the third significant figure, 1.756. Do you understand what I mean? xD Sorry if it's a bit unclear...
    Last edited by Zelaine; 09-18-2013 at 10:14 PM.

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,789
    Rep Power
    7

Similar Threads

  1. I need help rounding
    By MrPosotive in forum New To Java
    Replies: 2
    Last Post: 09-27-2012, 04:59 PM
  2. Rounding
    By Moncleared in forum New To Java
    Replies: 2
    Last Post: 11-17-2009, 08:16 AM
  3. [SOLVED] Rounding off numbers
    By Manfizy in forum New To Java
    Replies: 4
    Last Post: 02-07-2009, 12:44 AM
  4. rounding a double in a number of significant numbers
    By rikribbers in forum Advanced Java
    Replies: 2
    Last Post: 10-27-2008, 03:35 PM
  5. Need help rounding. =/
    By yo1mcool in forum New To Java
    Replies: 1
    Last Post: 10-07-2008, 05:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •