Package com.ericsson.otp.erlang

Examples of com.ericsson.otp.erlang.OtpErlangDouble


 
  @Test
  public void testParse6c()
  {
    String text = " 458888.5e-5 ";
    OtpErlangDouble number = (OtpErlangDouble)ErlangLabel.parseText(text);
    Assert.assertEquals(4.588885,number.doubleValue(),Configuration.fpAccuracy);
    Assert.assertEquals("4.588885",ErlangLabel.dumpErlangObject(runner.evaluateString(text)));
  }
View Full Code Here


 
  @Test
  public void testParse6d()
  {
    String text = " 458888.5e5 ";
    OtpErlangDouble number = (OtpErlangDouble)ErlangLabel.parseText(text);
    Assert.assertEquals(4.588885e10,number.doubleValue(),Configuration.fpAccuracy);
    Assert.assertEquals("4.588885E10",ErlangLabel.dumpErlangObject(runner.evaluateString(text)));
  }
View Full Code Here

 
  @Test
  public void testParse6e()
  {
    String text = " 4588.456e34 ";
    OtpErlangDouble number = (OtpErlangDouble)ErlangLabel.parseText(text);
    Assert.assertEquals(4.588456e37,number.doubleValue(),Configuration.fpAccuracy);
    Assert.assertEquals("4.588456E37",ErlangLabel.dumpErlangObject(runner.evaluateString(text)));
  }
View Full Code Here

 
  @Test
  public void testParse6f()
  {
    String text = " 4588888888888888.456e244 ";
    OtpErlangDouble number = (OtpErlangDouble)ErlangLabel.parseText(text);
    Assert.assertEquals(4.588888888888889E259,number.doubleValue(),Configuration.fpAccuracy);
    Assert.assertEquals("4.588888888888889E259",ErlangLabel.dumpErlangObject(runner.evaluateString(text)));
  }
View Full Code Here

 
  @Test
  public void testParse6g()
  {
    String text = " 4588888888888888.456e-244 ";
    OtpErlangDouble number = (OtpErlangDouble)ErlangLabel.parseText(text);
    Assert.assertEquals(4.588888888888888E-229,number.doubleValue(),Configuration.fpAccuracy);
    Assert.assertEquals("4.588888888888888E-229",ErlangLabel.dumpErlangObject(runner.evaluateString(text)));
  }
View Full Code Here

   */
  @Test
  public void testParse6ha()
  {
    final String text = " 4.0E"+(-ErlangLabel.ErlangLong.minExponent+1)+" ";
    OtpErlangDouble number = (OtpErlangDouble)ErlangLabel.parseText(text);
    Assert.assertEquals(4d*Math.pow(10, -ErlangLabel.ErlangLong.minExponent+1),number.doubleValue(),Configuration.fpAccuracy);
    Assert.assertEquals(text.trim(),ErlangLabel.dumpErlangObject(runner.evaluateString(text)));
  }
View Full Code Here

 
  @Test
  public void testParse6ia()
  {
    final String text = " 4.0E"+(ErlangLabel.ErlangLong.maxExponent)+" ";
    OtpErlangDouble number = (OtpErlangDouble)ErlangLabel.parseText(text);
    Assert.assertEquals(4d*Math.pow(10, ErlangLabel.ErlangLong.maxExponent),number.doubleValue(),Configuration.fpAccuracy);
    Assert.assertEquals(text.trim(),ErlangLabel.dumpErlangObject(runner.evaluateString(text)));
  }
View Full Code Here

  /** Erlang refuses to parse 4e10, I think this is wrong and hence my parser accepts this. */
  @Test
  public void testParse6j()
  {
    final String text = " 4e10 ";
    OtpErlangDouble number = (OtpErlangDouble)ErlangLabel.parseText(text);
    Assert.assertEquals(4e10,number.doubleValue(),Configuration.fpAccuracy);
    checkForCorrectException(new whatToRun() { public @Override void run() {
      runner.evaluateString(text);
    }},IllegalArgumentException.class,"badmatch");
  }
View Full Code Here

  /** Erlang refuses to parse 4.e10, I think this is wrong hence my parser accepts this. */
  @Test
  public void testParse6k()
  {
    final String text = " 4.e10 ";
    OtpErlangDouble number = (OtpErlangDouble)ErlangLabel.parseText(text);
    Assert.assertEquals(4e10,number.doubleValue(),Configuration.fpAccuracy);
    try
    {
      runner.evaluateString(text);
    }
    catch(Exception ex)
View Full Code Here

        double parsingResult = Double.parseDouble(textToParse);
        if (Double.isInfinite(parsingResult)
            || Double.isNaN(parsingResult))
          throw new IllegalArgumentException(
              "the number parsed cannot be represented as a double");
        result = new OtpErlangDouble(parsingResult);

      }
      return result;
    }
View Full Code Here

TOP

Related Classes of com.ericsson.otp.erlang.OtpErlangDouble

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.