Tabnine Logo
BigDecimal.toString
Code IndexAdd Tabnine to your IDE (free)

How to use
toString
method
in
java.math.BigDecimal

Best Java code snippets using java.math.BigDecimal.toString (Showing top 20 results out of 7,326)

Refine searchRefine arrow

  • BigDecimal.<init>
origin: stackoverflow.com

 BigDecimal bd = new BigDecimal("10.0001");
System.out.println(bd.toString()); // prints 10.0001
//or alternatively
BigDecimal bd = nBigDecimal.valueOf(10.0001);
System.out.println(bd.toString()); // prints 10.0001
origin: postgresql/postgresql

protected PGBigDecimal( BigDecimal x )
{
  // ensure the value is a valid numeric value to avoid
  // sql injection attacks
  val = new BigDecimal(x.toString());
  
}
origin: vipshop/vjtools

/**
 * 人民币金额单位转换,元转换成分,例如:1 => 100
 */
public static BigDecimal yuan2fen(BigDecimal y) {
  if (y != null) {
    return yuan2fen(y.toString());
  } else {
    return new BigDecimal(0);
  }
}
origin: stackoverflow.com

new BigDecimal("0.06").multiply(new BigDecimal("3")).toString()
origin: deeplearning4j/nd4j

/**
 * Return a string in floating point format.
 *
 * @param digits The precision (number of digits)
 * @return The human-readable version in base 10.
 */
public String toFString(int digits) {
  if (b.compareTo(BigInteger.ONE) != 0) {
    MathContext mc = new MathContext(digits, RoundingMode.DOWN);
    BigDecimal f = (new BigDecimal(a)).divide(new BigDecimal(b), mc);
    return (f.toString());
  } else {
    return a.toString();
  }
} /* Rational.toFString */
origin: google/guava

/**
 * Computes the mean in a way that is obvious and resilient to overflow by using BigInteger
 * arithmetic.
 */
private static int computeMeanSafely(int x, int y) {
 BigInteger bigX = BigInteger.valueOf(x);
 BigInteger bigY = BigInteger.valueOf(y);
 BigDecimal bigMean =
   new BigDecimal(bigX.add(bigY)).divide(BigDecimal.valueOf(2), BigDecimal.ROUND_FLOOR);
 // parseInt blows up on overflow as opposed to intValue() which does not.
 return Integer.parseInt(bigMean.toString());
}
origin: google/guava

/**
 * Computes the mean in a way that is obvious and resilient to overflow by using BigInteger
 * arithmetic.
 */
private static long computeMeanSafely(long x, long y) {
 BigInteger bigX = BigInteger.valueOf(x);
 BigInteger bigY = BigInteger.valueOf(y);
 BigDecimal bigMean =
   new BigDecimal(bigX.add(bigY)).divide(BigDecimal.valueOf(2), BigDecimal.ROUND_FLOOR);
 // parseInt blows up on overflow as opposed to intValue() which does not.
 return Long.parseLong(bigMean.toString());
}
origin: G-Joker/WeaponApp

/**
 *
 * 提供精确的加法运算
 *
 * @param v1
 *
 * @param v2
 *
 * @return 两个参数数学加和,以字符串格式返回
 */
public static String add(String v1, String v2) {
  try {
    BigDecimal b1 = new BigDecimal(v1);
    BigDecimal b2 = new BigDecimal(v2);
    return b1.add(b2).toString();
  } catch (Exception e) {
    return "0";
  }
}
origin: G-Joker/WeaponApp

/**
 *
 * 提供精确的加法运算
 *
 * @param v1
 *
 * @param v2
 *
 * @return 两个参数数学加和,以字符串格式返回
 */
public static String add(String v1, String v2) {
  try {
    BigDecimal b1 = new BigDecimal(v1);
    BigDecimal b2 = new BigDecimal(v2);
    return b1.add(b2).toString();
  } catch (Exception e) {
    return "0";
  }
}
origin: G-Joker/WeaponApp

/**
 *
 * 提供精确的减法运算
 *
 * @param v1
 *
 * @param v2
 *
 * @return 两个参数数学差,以字符串格式返回
 */
public static String subtract(String v1, String v2)
{
  try {
    BigDecimal b1 = new BigDecimal(v1);
    BigDecimal b2 = new BigDecimal(v2);
    return b1.subtract(b2).toString();
  } catch (Exception e) {
    return "0";
  }
}
origin: G-Joker/WeaponApp

/**
 *
 * 提供精确的减法运算
 *
 * @param v1
 *
 * @param v2
 *
 * @return 两个参数数学差,以字符串格式返回
 */
public static String subtract(String v1, String v2)
{
  try {
    BigDecimal b1 = new BigDecimal(v1);
    BigDecimal b2 = new BigDecimal(v2);
    return b1.subtract(b2).toString();
  } catch (Exception e) {
    return "0";
  }
}
origin: G-Joker/WeaponApp

/**
 *
 * 提供精确的乘法运算
 *
 * @param v1
 *
 * @param v2
 *
 * @return 两个参数的数学积,以字符串格式返回
 */
public static String multiply(String v1, String v2)
{
  try {
    BigDecimal b1 = new BigDecimal(v1);
    BigDecimal b2 = new BigDecimal(v2);
    return b1.multiply(b2).toString();
  } catch (Exception e) {
    return "0";
  }
}
origin: G-Joker/WeaponApp

/**
 *
 * 提供精确的乘法运算
 *
 * @param v1
 *
 * @param v2
 *
 * @return 两个参数的数学积,以字符串格式返回
 */
public static String multiply(String v1, String v2)
{
  try {
    BigDecimal b1 = new BigDecimal(v1);
    BigDecimal b2 = new BigDecimal(v2);
    return b1.multiply(b2).toString();
  } catch (Exception e) {
    return "0";
  }
}
origin: apache/hive

 public static String createJdoDecimalString(Decimal d) {
  return new BigDecimal(new BigInteger(d.getUnscaled()), d.getScale()).toString();
 }
}
origin: apache/drill

@Override
public Void visitDecimal18Constant(Decimal18Expression decExpr, StringBuilder sb) throws RuntimeException {
 BigDecimal value = new BigDecimal(decExpr.getLongFromDecimal());
 sb.append((value.setScale(decExpr.getScale())).toString());
 return null;
}
origin: apache/drill

@Override
public Void visitDecimal9Constant(Decimal9Expression decExpr, StringBuilder sb) throws RuntimeException {
 BigDecimal value = new BigDecimal(decExpr.getIntFromDecimal());
 sb.append((value.setScale(decExpr.getScale())).toString());
 return null;
}
origin: jiangqqlmj/FastDev4Android

public static String getReadableSize(long length) {
  if (length >= 0 && length < SIZE_BT) {
    // Math.round四舍五入
    return (double) (Math.round(length * 10) / 10.0) + "B";
  } else if (length >= SIZE_BT && length < SIZE_KB) {
    // //length/SIZE_BT+"KB";
    return (double) (Math.round((length / SIZE_BT) * 10) / 10.0) + "KB";
  } else if (length >= SIZE_KB && length < SIZE_MB) {
    // length/SIZE_KB+"MB";
    return (double) (Math.round((length / SIZE_KB) * 10) / 10.0) + "MB";
  } else if (length >= SIZE_MB && length < SIZE_GB) {
    // bigdecimal这个对象进行数据相互除
    BigDecimal longs = new BigDecimal(Double.valueOf(length + "")
        .toString());
    BigDecimal sizeMB = new BigDecimal(Double.valueOf(SIZE_MB + "")
        .toString());
    String result = longs.divide(sizeMB, SACLE,
        BigDecimal.ROUND_HALF_UP).toString();
    return result + "GB";
  } else {
    // bigdecimal这个对象进行数据相互除
    BigDecimal longs = new BigDecimal(Double.valueOf(length + "")
        .toString());
    BigDecimal sizeMB = new BigDecimal(Double.valueOf(SIZE_GB + "")
        .toString());
    String result = longs.divide(sizeMB, SACLE,
        BigDecimal.ROUND_HALF_UP).toString();
    return result + "TB";
  }
}
origin: G-Joker/WeaponApp

  BigDecimal b1 = new BigDecimal(v1);
  BigDecimal b2 = new BigDecimal(v2);
  return b1.divide(b2, scale, round_mode).toString();
} catch (Exception e) {
  return "0";
origin: G-Joker/WeaponApp

  BigDecimal b1 = new BigDecimal(v1);
  BigDecimal b2 = new BigDecimal(v2);
  return b1.divide(b2, scale, round_mode).toString();
} catch (Exception e) {
  return "0";
origin: stackoverflow.com

  df.setParseBigDecimal(true);
  BigDecimal bd = (BigDecimal) df.parseObject(numberString);
  System.out.println(bd.toString());
} catch (ParseException e) {
  e.printStackTrace();
  BigDecimal bd1 = new BigDecimal(nf.parse(numberString).toString());
  System.out.println(bd1.toString());
} catch (ParseException e) {
  e.printStackTrace();
System.out.println(new BigDecimal(numberStringFixed));;     
System.out.println(new BigDecimal(numberString));;
java.mathBigDecimaltoString

Javadoc

Returns a canonical string representation of this BigDecimal. If necessary, scientific notation is used. This representation always prints all significant digits of this value.

If the scale is negative or if scale - precision >= 6 then scientific notation is used.

Popular methods of BigDecimal

  • <init>
    Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same se
  • valueOf
  • compareTo
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • doubleValue
    Converts this BigDecimal to a double. This conversion is similar to thenarrowing primitive conversio
  • setScale
    Returns a BigDecimal whose scale is the specified value, and whose unscaled value is determined by m
  • divide
  • add
  • multiply
  • subtract
    Returns a BigDecimal whose value is (this - subtrahend), with rounding according to the context sett
  • intValue
    Converts this BigDecimal to an int. This conversion is analogous to thenarrowing primitive conversio
  • longValue
    Converts this BigDecimal to a long. This conversion is analogous to thenarrowing primitive conversio
  • toPlainString
    Returns a string representation of this BigDecimalwithout an exponent field. For values with a posit
  • longValue,
  • toPlainString,
  • scale,
  • toBigInteger,
  • equals,
  • floatValue,
  • negate,
  • unscaledValue,
  • abs

Popular in Java

  • Finding current android device location
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • onRequestPermissionsResult (Fragment)
  • setRequestProperty (URLConnection)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Kernel (java.awt.image)
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JComboBox (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now