0
I would like to know how to format a doouble with two boxes to the left of the dot and two to the right of the dot.
Example: I have double 1.1
I want it formatted to 01.10;
input: 10.1 / 1.05
output : 10.01 / 01.05
0
I would like to know how to format a doouble with two boxes to the left of the dot and two to the right of the dot.
Example: I have double 1.1
I want it formatted to 01.10;
input: 10.1 / 1.05
output : 10.01 / 01.05
Browser other questions tagged java decimal number-format double
You are not signed in. Login or sign up in order to post.
Possible duplicate of http://answall.com/questions/30701/formata%C3%A7%C3%A3o-de-um-double-in-java? Rq=1
– DH.
Actually I wanted the double to be formatted and not a string. When I use the example mentioned in the linked topic it is formatting to 10.0, when I wanted it to format to 10.00. Decimalformat = new Decimalformat("#.##"); number = Double.valueOf(format.format(number)); System.out.println(number); output: 10.0
– Raphael Coelho
I need to sort the values of double 01.20 is higher than 01.11 but is considering 01.2 ,so the ordering is wrong.
– Raphael Coelho
What you said doesn’t make sense.
1.2 > 1.11
In math, it’s not because you’re missing a zero that 1.11 is bigger. Double is a number, zeros on the left make no difference in any operation, just as zeros on the right after comma also do not.– DH.
I don’t think you understand. The system carries a list of decimal numbers. [1.5; 1.10; 1.15; 2.5] when I sort these numbers sort as follows: [1.1; 1.15;1.5;2.5] that is, the zero of 1.10 has been de-activated.
– Raphael Coelho
Yes, because zero right after comma does not interfere with anything. Ordering is perfect. I don’t understand what result you want.
– DH.
The problem is that [1.10 ; 1.9 ; 1.0] is getting [1.0 ; 1.1 ; 1.9], my question is how do I consider 1.10 and not 1.1
– Raphael Coelho
Make it whole in ordination then. I say,
110 > 19 > 10
, I imagine that’s what you want.– DH.
Thanks man! I turned it into a whole and it worked.
– Raphael Coelho