root / trunk / extensions / extQuickInfo / src-test / org / gvsig / quickInfo / TestFormatDecimalNumber.java @ 27817
History | View | Annotate | Download (3.47 KB)
1 |
package org.gvsig.quickInfo; |
---|---|
2 |
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government
|
4 |
*
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
6 |
* of the Valencian Government (CIT)
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
21 |
* MA 02110-1301, USA.
|
22 |
*
|
23 |
*/
|
24 |
|
25 |
import javax.swing.JOptionPane; |
26 |
|
27 |
import org.gvsig.quickInfo.i18n.Messages; |
28 |
|
29 |
|
30 |
/**
|
31 |
* <p>Tests the method {@link FormatDecimalNumber FormatDecimalNumber}</p>
|
32 |
*
|
33 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
34 |
*/
|
35 |
public class TestFormatDecimalNumber { |
36 |
/**
|
37 |
* Tests the method {@link FormatDecimalNumbe#formatDecimal(double) FormatDecimalNumbe#formatDecimal(double)}
|
38 |
*
|
39 |
* @param args
|
40 |
*/
|
41 |
public static void main(String args[]) { |
42 |
try {
|
43 |
double num = 123412341234.123412351235123451235123; |
44 |
System.out.println(num);
|
45 |
System.out.println(FormatDecimalNumber.formatDecimal(num));
|
46 |
System.out.println("----------------------------"); |
47 |
|
48 |
num = 0.00000123412341234123412351235123451235123;
|
49 |
System.out.println(num);
|
50 |
System.out.println(FormatDecimalNumber.formatDecimal(num));
|
51 |
System.out.println("----------------------------"); |
52 |
|
53 |
num = 123412341234123412351235123451235123.0;
|
54 |
System.out.println(num);
|
55 |
System.out.println(FormatDecimalNumber.formatDecimal(num));
|
56 |
System.out.println("----------------------------"); |
57 |
|
58 |
num = -123;
|
59 |
System.out.println(num);
|
60 |
System.out.println(FormatDecimalNumber.formatDecimal(num));
|
61 |
System.out.println("----------------------------"); |
62 |
|
63 |
num = 0.00123;
|
64 |
System.out.println(num);
|
65 |
System.out.println(FormatDecimalNumber.formatDecimal(num));
|
66 |
System.out.println("----------------------------"); |
67 |
|
68 |
num = -0.923;
|
69 |
System.out.println(num);
|
70 |
System.out.println(FormatDecimalNumber.formatDecimal(num));
|
71 |
System.out.println("----------------------------"); |
72 |
|
73 |
num = 0.0000225;
|
74 |
System.out.println(num);
|
75 |
System.out.println(FormatDecimalNumber.formatDecimal(num));
|
76 |
System.out.println("----------------------------"); |
77 |
|
78 |
num = 0.00000225;
|
79 |
System.out.println(num);
|
80 |
System.out.println(FormatDecimalNumber.formatDecimal(num));
|
81 |
System.out.println("----------------------------"); |
82 |
|
83 |
num = 1234567890;
|
84 |
System.out.println(num);
|
85 |
System.out.println(FormatDecimalNumber.formatDecimal(num));
|
86 |
System.out.println("----------------------------"); |
87 |
|
88 |
num = 1223456789;
|
89 |
System.out.println(num);
|
90 |
System.out.println(FormatDecimalNumber.formatDecimal(num));
|
91 |
System.out.println("----------------------------"); |
92 |
|
93 |
num = 12.2345678901E9;
|
94 |
System.out.println(num);
|
95 |
System.out.println(FormatDecimalNumber.formatDecimal(num));
|
96 |
System.out.println("----------------------------"); |
97 |
} catch(Exception e) { |
98 |
e.printStackTrace(); |
99 |
JOptionPane.showMessageDialog(null, Messages.getText("An_exception_happened"), Messages.getText("Error"), JOptionPane.ERROR_MESSAGE); |
100 |
} |
101 |
|
102 |
return;
|
103 |
} |
104 |
} |