Examples of toBigIntegerExact()


Examples of java.math.BigDecimal.toBigIntegerExact()

     */
    public void testToBigIntegerExactException() {
        String a = "-123809648392384754573567356745735.63567890295784902768787678287E-10";
        BigDecimal aNumber = new BigDecimal(a);
        try {
            aNumber.toBigIntegerExact();
            fail("java.lang.ArithmeticException has not been thrown");
        } catch (java.lang.ArithmeticException e) {
            return;
        }
    }
View Full Code Here

Examples of java.math.BigDecimal.toBigIntegerExact()

            CorruptIndexException e = new CorruptIndexException("failed to parse BigDecimal value (resource=" + in + ")");
            e.initCause(pe);
            throw e;
          }
          SimpleTextUtil.readLine(in, scratch); // read the line telling us if its real or not
          return BigInteger.valueOf(field.minValue).add(bd.toBigIntegerExact()).longValue();
        } catch (IOException ioe) {
          throw new RuntimeException(ioe);
        }
      }
    };
View Full Code Here

Examples of java.math.BigDecimal.toBigIntegerExact()

            throw new ClassCastException("Cannot bind Java "+oVal.getClass().getName()+" into "+sKey+" "+oAttr.type().getDataType().name());
        } else if (oVal instanceof BigDecimal) {
          oAttr = oDoc.attribute(sKey);
          BigDecimal oDec = (BigDecimal) oVal;
          try {
            BigInteger oBig = oDec.toBigIntegerExact();
            oAttr.set(oBig.longValue());               
            } catch (ArithmeticException ex) {
            oAttr.set(oDec);
            }
        } else if (oVal instanceof Integer) {
View Full Code Here

Examples of java.math.BigDecimal.toBigIntegerExact()

  }

  public String getPrice(Locale oLoc) {
    BigDecimal oDec = getPrice();
    try {
      BigInteger oBig = oDec.toBigIntegerExact();
      return oBig.toString();           
    } catch (ArithmeticException ex) {
      DecimalFormat oFmt = new DecimalFormat("#.##", new DecimalFormatSymbols(oLoc));
      return oFmt.format(oDec);
    }
View Full Code Here

Examples of java.math.BigDecimal.toBigIntegerExact()

  public String getPercentage() {
    BigDecimal oPercentage = getValue().multiply(new BigDecimal("100"));
    String sPercentage;
    try {
      BigInteger oIntPercentage = oPercentage.toBigIntegerExact();
      sPercentage = oIntPercentage.toString();
    } catch (ArithmeticException ex) {
      sPercentage = oPercentage.toString();
    }   
    return sPercentage+"%";
View Full Code Here

Examples of java.math.BigDecimal.toBigIntegerExact()

          } catch (ParseException pe) {
            CorruptIndexException e = new CorruptIndexException("failed to parse BigDecimal value");
            e.initCause(pe);
            throw e;
          }
          return BigInteger.valueOf(field.minValue).add(bd.toBigIntegerExact()).longValue();
        } catch (IOException ioe) {
          throw new RuntimeException(ioe);
        }
      }
    };
View Full Code Here

Examples of java.math.BigDecimal.toBigIntegerExact()

                case Remainder:
                    return GoTypes.constant(GoTypeConstant.Kind.Float, leftValue.divideAndRemainder(rightValue)[1]);
                case ShiftLeft:
                    try {
                        BigInteger leftInteger = leftValue.toBigIntegerExact();
                        BigInteger rightInteger = rightValue.toBigIntegerExact();

                        return GoTypes.constant(GoTypeConstant.Kind.Integer, leftInteger.shiftLeft(rightInteger.intValue()));
                    } catch (ArithmeticException ex) {
                        return GoType.Unknown;
                    }
View Full Code Here

Examples of java.math.BigDecimal.toBigIntegerExact()

                        return GoType.Unknown;
                    }
                case ShiftRight:
                    try {
                        BigInteger leftInteger = leftValue.toBigIntegerExact();
                        BigInteger rightInteger = rightValue.toBigIntegerExact();

                        return GoTypes.constant(GoTypeConstant.Kind.Integer, leftInteger.shiftRight(rightInteger.intValue()));
                    } catch (ArithmeticException ex) {
                        return GoType.Unknown;
                    }
View Full Code Here

Examples of java.math.BigDecimal.toBigIntegerExact()

            decimal = (decimal == null) ? constant.getValueAs(BigDecimal.class) : decimal;
            if (decimal == null)
                return null;

            try {
                integer = decimal.toBigIntegerExact();
            } catch (ArithmeticException e) {
                return null;
            }
        }
View Full Code Here

Examples of java.math.BigDecimal.toBigIntegerExact()

        return json.getAsString();
      else {
        BigDecimal bigDec = json.getAsBigDecimal();
        // Find out if it is an int type
        try {
          bigDec.toBigIntegerExact();
          try { return bigDec.intValueExact(); }
          catch(ArithmeticException e) {}
          return bigDec.longValue();
        } catch(ArithmeticException e) {}
        // Just return it as a double
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.