• Log in or sign up for an account here: https://www.sythe.org/login

Small question from a newbie

Tiemen

Grand Master
Banned
Joined
Mar 21, 2010
Sythe Gold
0
Messages
3,913
Small question from a newbie
I'm currently making a task for university but i cant find this in my sillabus anywhere :O
How can i round a double to a certain amount of digits?
I know the things like Math.floor, Math.ceil, Math.rint and Math.round....

So basically i want

1.111 instead of 1.1111111111111112
 
Small question from a newbie
Small question from a newbie
Code:
public class roundToThree {
     public static void main(String[] args){
             DecimalFormat twoDForm = new DecimalFormat("#.###");
              System.out.println(twoDForm.format(10.1234));
     }
}
 
Small question from a newbie
Thanks for the replies :)
Anyways, created my own method already to do it (multiply, round, divide), so I only use things I've learnt yet :D
 
Runescape Gamblingrunescape gambling
Back
Top