]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/primitives/MutableDouble.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / primitives / MutableDouble.java
1 /*******************************************************************************
2  *  Copyright (c) 2010 Association for Decentralized Information Management in
3  *  Industry THTH ry.
4  *  All rights reserved. This program and the accompanying materials
5  *  are made available under the terms of the Eclipse Public License v1.0
6  *  which accompanies this distribution, and is available at
7  *  http://www.eclipse.org/legal/epl-v10.html
8  *
9  *  Contributors:
10  *      VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.primitives;
13
14 public class MutableDouble extends Number implements Comparable<MutableDouble> {
15
16         private static final long serialVersionUID = 1L;
17         
18         public double value;
19         
20         public MutableDouble() {}
21         
22         public MutableDouble(double value) { this.value = value; }
23         
24         public boolean isNaN() {
25                 return Double.isNaN(value);
26         }
27
28         public boolean isInfinite() {
29                 return Double.isInfinite(value);
30         }
31
32         public String toString() {
33                 return String.valueOf(value);
34         }
35
36         public byte byteValue() {
37                 return (byte) value;
38         }
39
40         public short shortValue() {
41                 return (short) value;
42         }
43
44         public int intValue() {
45                 return (int) value;
46         }
47
48         public long longValue() {
49                 return (long) value;
50         }
51
52         public float floatValue() {
53                 return (float) value;
54         }
55
56         public double doubleValue() {
57                 return (double) value;
58         }
59
60         public int hashCode() {
61                 long bits = Double.doubleToLongBits(value);
62                 return (int) (bits ^ (bits >>> 32));
63         }
64
65         public boolean equals(Object obj) {
66                 return (obj instanceof MutableDouble)
67                                 && (Double.doubleToLongBits(((MutableDouble) obj).value) == Double
68                                                 .doubleToLongBits(value));
69         }
70
71         public int compareTo(MutableDouble anotherDouble) {
72                 return Double.compare(value, anotherDouble.value);
73         }
74
75 }
76