本文整理汇总了Java中java.math.BigDecimal.toPlainString方法的典型用法代码示例。如果您正苦于以下问题:Java BigDecimal.toPlainString方法的具体用法?Java BigDecimal.toPlainString怎么用?Java BigDecimal.toPlainString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.math.BigDecimal
的用法示例。
在下文中一共展示了BigDecimal.toPlainString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import java.math.BigDecimal; //导入方法依赖的package包/类
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull(SerializerFeature.WriteNullNumberAsZero);
} else {
BigDecimal val = (BigDecimal) object;
String outText;
if (out.isEnabled(SerializerFeature.WriteBigDecimalAsPlain)) {
outText = val.toPlainString();
} else {
outText = val.toString();
}
out.write(outText);
if (out.isEnabled(SerializerFeature.WriteClassName) && fieldType != BigDecimal.class && val.scale() == 0) {
out.write('.');
}
}
}
示例2: bind
import java.math.BigDecimal; //导入方法依赖的package包/类
@Override
public void bind(@Nullable Token data, @NonNull Bundle addition) {
this.token = data;
if (data == null) {
fillEmpty();
return;
}
try {
symbol.setText(token.tokenInfo.symbol);
BigDecimal decimalDivisor = new BigDecimal(Math.pow(10, token.tokenInfo.decimals));
BigDecimal ethBalance = token.tokenInfo.decimals > 0
? token.balance.divide(decimalDivisor) : token.balance;
String value = ethBalance.compareTo(BigDecimal.ZERO) == 0
? "0"
: ethBalance.toPlainString();
this.balance.setText(value);
} catch (Exception e) {
fillEmpty();
}
}
示例3: toString
import java.math.BigDecimal; //导入方法依赖的package包/类
public static String toString(BigDecimal o) {
if (o == null) {
return null;
}
//#ifdef JAVA6
return o.toPlainString();
//#else
/*
return o.toString();
*/
//#endif JAVA6
}
示例4: solve
import java.math.BigDecimal; //导入方法依赖的package包/类
/************************ SOLUTION STARTS HERE ************************/
private static void solve() {
String line;
while((line = nextLine()) != null) {
double a = Double.parseDouble(line.substring(0, 6).trim());
int b = Integer.parseInt(line.substring(7).trim());
BigDecimal power = BigDecimal.valueOf(a).pow(b);
try {
println(power.toBigIntegerExact());
}
catch(ArithmeticException e) {
String str = power.toPlainString();
if(str.charAt(0) == '0')
str = str.substring(1);
println(str);
}
}
}
示例5: toString
import java.math.BigDecimal; //导入方法依赖的package包/类
@Override
public String toString() {
BigDecimal v = new BigDecimal(value);
v = v.divide(new BigDecimal(D), 8, BigDecimal.ROUND_UNNECESSARY);
return v.toPlainString();
}
示例6: apply
import java.math.BigDecimal; //导入方法依赖的package包/类
@Override
public final String apply(BigDecimal input) {
if (input == null) {
final String nullString = getNullValue().get();
return nullString != null ? nullString : "null";
} else {
return input.toPlainString();
}
}
示例7: getFormattedValue
import java.math.BigDecimal; //导入方法依赖的package包/类
public static String getFormattedValue(BigDecimal b) {
BigDecimal number = b.setScale(0, RoundingMode.FLOOR);
boolean hasDecimal = number.compareTo(b) != 0;
if (hasDecimal) {
return String.format("%.2f", b);
} else {
return number.toPlainString();
}
}
示例8: FieldLiteral
import java.math.BigDecimal; //导入方法依赖的package包/类
/**
* Constructs a new {@linkplain FieldLiteral} with a BigDecimal source.
*
* @param bigDecimalValue the literal value to use
*/
public FieldLiteral(BigDecimal bigDecimalValue) {
super();
this.value = bigDecimalValue != null ? bigDecimalValue.toPlainString() : null;
this.dataType = DataType.DECIMAL;
}
示例9: appendNetDiscountCriterion
import java.math.BigDecimal; //导入方法依赖的package包/类
private void appendNetDiscountCriterion(Document doc,
ChargingData chargingData, Element analysisNode) {
Element netDiscountCriterion = doc
.createElement(HeidelpayXMLTags.XML_ANALYSIS_CRITERION);
netDiscountCriterion.setAttribute(HeidelpayXMLTags.XML_ATTRIBUTE_NAME,
HeidelpayXMLTags.XML_ANALYSIS_AMOUNT_NET_DISCOUNT);
BigDecimal netDiscount = chargingData.getNetDiscount();
String netDiscountAsString = netDiscount == null ? "null" : netDiscount
.toPlainString();
netDiscountCriterion.setTextContent(netDiscountAsString);
if (netDiscount != null) {
analysisNode.appendChild(netDiscountCriterion);
}
}
示例10: TX
import java.math.BigDecimal; //导入方法依赖的package包/类
private TX(int id, String desc, BigDecimal amount){
this.amount = new SimpleStringProperty(amount.toPlainString());
this.desc = new SimpleStringProperty(desc);
this.id = new SimpleIntegerProperty(id);
this.sortID = id;
this.timeFilled = new SimpleLongProperty(0);
this.status = new SimpleStringProperty("Requested");
this.pin = new SimpleStringProperty("");
}
示例11: DoubleColumn
import java.math.BigDecimal; //导入方法依赖的package包/类
public DoubleColumn(final BigDecimal data) {
this(null == data ? (String) null : data.toPlainString());
}
示例12: _printDecimal
import java.math.BigDecimal; //导入方法依赖的package包/类
public static String _printDecimal(BigDecimal val) {
return val.toPlainString();
}
示例13: formatSignificant
import java.math.BigDecimal; //导入方法依赖的package包/类
public static String formatSignificant(double value, int significant) {
MathContext mathContext = new MathContext(significant, RoundingMode.DOWN);
BigDecimal bigDecimal = new BigDecimal(value, mathContext);
return bigDecimal.toPlainString();
}
示例14: encodeText
import java.math.BigDecimal; //导入方法依赖的package包/类
@Override
public final String encodeText(final BigDecimal value) {
return value.toPlainString();
}
示例15: toText
import java.math.BigDecimal; //导入方法依赖的package包/类
public String toText() {
BigDecimal amount = new BigDecimal(value).divide(BigDecimal.valueOf(Na.NA.value));
return amount.toPlainString();
}