Package java.math

Examples of java.math.BigDecimal.floatValue()


   * @tests java.math.BigDecimal#floatValue()
   */
  public void test_floatValue() {
    BigDecimal fl1 = new BigDecimal("234563782344567");
    assertTrue("the float representation of bigDecimal 234563782344567",
        fl1.floatValue() == 234563782344567f);
    BigDecimal fl2 = new BigDecimal(2.345E37);
    assertTrue("the float representation of bigDecimal 2.345E37", fl2
        .floatValue() == 2.345E37F);
    fl2 = new BigDecimal(-1.00E-44);
    assertTrue("the float representation of bigDecimal -1.00E-44", fl2
View Full Code Here


  public void test_floatValue() {
    BigDecimal fl1 = new BigDecimal("234563782344567");
    assertTrue("the float representation of bigDecimal 234563782344567",
        fl1.floatValue() == 234563782344567f);
    BigDecimal fl2 = new BigDecimal(2.345E37);
    assertTrue("the float representation of bigDecimal 2.345E37", fl2
        .floatValue() == 2.345E37F);
    fl2 = new BigDecimal(-1.00E-44);
    assertTrue("the float representation of bigDecimal -1.00E-44", fl2
        .floatValue() == -1.00E-44F);
    fl2 = new BigDecimal(-3E12);
View Full Code Here

        fl1.floatValue() == 234563782344567f);
    BigDecimal fl2 = new BigDecimal(2.345E37);
    assertTrue("the float representation of bigDecimal 2.345E37", fl2
        .floatValue() == 2.345E37F);
    fl2 = new BigDecimal(-1.00E-44);
    assertTrue("the float representation of bigDecimal -1.00E-44", fl2
        .floatValue() == -1.00E-44F);
    fl2 = new BigDecimal(-3E12);
    assertTrue("the float representation of bigDecimal -3E12", fl2
        .floatValue() == -3E12F);
    fl2 = new BigDecimal(Double.MAX_VALUE);
View Full Code Here

        .floatValue() == 2.345E37F);
    fl2 = new BigDecimal(-1.00E-44);
    assertTrue("the float representation of bigDecimal -1.00E-44", fl2
        .floatValue() == -1.00E-44F);
    fl2 = new BigDecimal(-3E12);
    assertTrue("the float representation of bigDecimal -3E12", fl2
        .floatValue() == -3E12F);
    fl2 = new BigDecimal(Double.MAX_VALUE);
    assertTrue(
        "A number can't be represented by float should return infinity",
        fl2.floatValue() == Float.POSITIVE_INFINITY);
View Full Code Here

    assertTrue("the float representation of bigDecimal -3E12", fl2
        .floatValue() == -3E12F);
    fl2 = new BigDecimal(Double.MAX_VALUE);
    assertTrue(
        "A number can't be represented by float should return infinity",
        fl2.floatValue() == Float.POSITIVE_INFINITY);
    fl2 = new BigDecimal(-Double.MAX_VALUE);
    assertTrue(
        "A number can't be represented by float should return infinity",
        fl2.floatValue() == Float.NEGATIVE_INFINITY);
View Full Code Here

        "A number can't be represented by float should return infinity",
        fl2.floatValue() == Float.POSITIVE_INFINITY);
    fl2 = new BigDecimal(-Double.MAX_VALUE);
    assertTrue(
        "A number can't be represented by float should return infinity",
        fl2.floatValue() == Float.NEGATIVE_INFINITY);

  }

  /**
   * @tests java.math.BigDecimal#hashCode()
View Full Code Here

      if ("BigDecimal".equals(type) || "java.math.BigDecimal".equals(type))
        return obj;
      if ("Double".equals(type))
        return new Double(bigD.doubleValue());
      if ("Float".equals(type))
        return new Float(bigD.floatValue());
      if ("Long".equals(type))
        return new Long(Math.round(bigD.doubleValue()));
      if ("Integer".equals(type))
        return new Integer((int) Math.round(bigD.doubleValue()));
      else
View Full Code Here

        return values.get(index);
      case SUM:
        BigDecimal sum = new BigDecimal(0);
        for (int i = 0; i < values.size(); ++i)
          sum = sum.add(new BigDecimal(values.get(i)));
        return sum.floatValue();
      case MIN:
        BigDecimal minimum = new BigDecimal(values.get(0));
        for (int i = 1; i < values.size(); ++i)
          if (minimum.compareTo(new BigDecimal(values.get(i))) > 0)
            minimum = new BigDecimal(values.get(i));
View Full Code Here

      case MIN:
        BigDecimal minimum = new BigDecimal(values.get(0));
        for (int i = 1; i < values.size(); ++i)
          if (minimum.compareTo(new BigDecimal(values.get(i))) > 0)
            minimum = new BigDecimal(values.get(i));
        return minimum.floatValue();
      case MAX:
        BigDecimal maximum = new BigDecimal(values.get(0));
        for (int i = 1; i < values.size(); ++i)
          if (maximum.compareTo(new BigDecimal(values.get(i))) < 0)
            maximum = new BigDecimal(values.get(i));
View Full Code Here

      case MAX:
        BigDecimal maximum = new BigDecimal(values.get(0));
        for (int i = 1; i < values.size(); ++i)
          if (maximum.compareTo(new BigDecimal(values.get(i))) < 0)
            maximum = new BigDecimal(values.get(i));
        return maximum.floatValue();
      case FIRST:
        return values.get(0);
      case LAST:
        return values.get(values.size() - 1);
      default:
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.