View Javadoc
1   package org.djutils.float128;
2   
3   import java.io.Serializable;
4   
5   /**
6    * DoubleDouble stores a value as two double values, with a hi double value and a lo double value. The lo double value has a
7    * value of around 1.0E13 lower magnitude than the hi double value. The value that is represented by the DoubleDouble has the
8    * value hi+lo. DoubleDouble is immutable. <br>
9    * <br>
10   * Copyright (c) 2020-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
11   * for project information <a href="https://djutils.org" target="_blank"> https://djutils.org</a>. The DJUTILS project is
12   * distributed under a three-clause BSD-style license, which can be found at
13   * <a href="https://djutils.org/docs/license.html" target="_blank"> https://djutils.org/docs/license.html</a>. <br>
14   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
15   * @author <a href="https://www.tudelft.nl/pknoppers">Peter Knoppers</a>
16   */
17  public class DoubleDouble extends Number implements Serializable, Comparable<DoubleDouble>
18  {
19      /** the high part of the DoubleDouble value. */
20      private final double hi;
21  
22      /** the low part of the DoubleDouble value. */
23      private final double lo;
24  
25      /**
26       * Construct a new DoubleDouble value consisting of a high (most significant) part and a low (least significant) part.
27       * @param hi double; the high part of the DoubleDouble value
28       * @param lo double; the low part of the DoubleDouble value
29       */
30      public DoubleDouble(final double hi, final double lo)
31      {
32          this.hi = hi;
33          this.lo = lo;
34      }
35  
36      /**
37       * Construct a new DoubleDouble value using one double, where the lo part of the DoubleDouble will be 0.
38       * @param value double; the high part of the DoubleDouble value
39       */
40      public DoubleDouble(final double value)
41      {
42          this(value, 0.0);
43      }
44  
45      /**
46       * Construct a DoubleDouble from a String value.
47       * @param s String; the String value to be parsed 
48       * @return a DoubleDouble value representing s with as many correct digits as possible
49       */
50      public static DoubleDouble valueOf(final String s)
51      {
52          int exp = 0;
53          if (s.indexOf('e') >=0 || s.indexOf('E') >=0)
54          {
55              exp = Integer.valueOf(s.substring(0));
56          }
57          double hi = Double.valueOf(s);
58          return null;
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public int compareTo(final DoubleDouble o)
64      {
65          return 0;
66      }
67  
68      /** {@inheritDoc} */
69      @Override
70      public int intValue()
71      {
72          return 0;
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public long longValue()
78      {
79          return 0;
80      }
81  
82      /** {@inheritDoc} */
83      @Override
84      public float floatValue()
85      {
86          return 0;
87      }
88  
89      /** {@inheritDoc} */
90      @Override
91      public double doubleValue()
92      {
93          return 0;
94      }
95  }