当前位置: 首页>>代码示例>>Java>>正文


Java BigDecimal.setScale方法代码示例

本文整理汇总了Java中java.math.BigDecimal.setScale方法的典型用法代码示例。如果您正苦于以下问题:Java BigDecimal.setScale方法的具体用法?Java BigDecimal.setScale怎么用?Java BigDecimal.setScale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.math.BigDecimal的用法示例。


在下文中一共展示了BigDecimal.setScale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testItem_0024

import java.math.BigDecimal; //导入方法依赖的package包/类
public void testItem_0024()
{
    BigDecimal alpha = new BigDecimal("1000").setScale(0);
    BigDecimal beta = new BigDecimal("0.70").setScale(2);
    BigDecimal gamma = alpha.subtract(beta);
    gamma.setScale(2);
    Assert.assertEquals("999.30", gamma.toString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:9,代码来源:TestSuite063.java

示例2: truncate

import java.math.BigDecimal; //导入方法依赖的package包/类
public Object truncate(Object a, int s) {

        if (a == null) {
            return null;
        }

        if (s >= scale) {
            return a;
        }

        BigDecimal dec = convertToDecimal(a);

        dec = dec.setScale(s, BigDecimal.ROUND_DOWN);
        dec = dec.setScale(scale, BigDecimal.ROUND_DOWN);

        return convertToDefaultType(null, dec);
    }
 
开发者ID:s-store,项目名称:s-store,代码行数:18,代码来源:NumberType.java

示例3: testItem_0069

import java.math.BigDecimal; //导入方法依赖的package包/类
public void testItem_0069()
{
    BigDecimal alpha = new BigDecimal(new BigInteger("1000"), 0);
    BigDecimal beta = new BigDecimal(new BigInteger("70"), 2);
    BigDecimal gamma = alpha.multiply(beta);
    gamma.setScale(1, BigDecimal.ROUND_DOWN);
    Assert.assertEquals("700.00", gamma.toString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:9,代码来源:TestSuite063.java

示例4: initialize

import java.math.BigDecimal; //导入方法依赖的package包/类
public IntegralDataTypeHolder initialize(ResultSet resultSet, long defaultValue) throws SQLException {
	final BigDecimal rsValue = resultSet.getBigDecimal( 1 );
	if ( resultSet.wasNull() ) {
		return initialize( defaultValue );
	}
	this.value = rsValue.setScale( 0, BigDecimal.ROUND_UNNECESSARY );
	return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:IdentifierGeneratorHelper.java

示例5: sendFrom

import java.math.BigDecimal; //导入方法依赖的package包/类
@Override
public String sendFrom(String fromAccount, String toAddress, BigDecimal amount, 
		Integer confirmations, String comment) throws CryptocoinException, 
		CommunicationException {
	amount = amount.setScale(Defaults.DECIMAL_SCALE, Defaults.ROUNDING_MODE);
	List<Object> params = CollectionUtils.asList(fromAccount, toAddress, amount, confirmations, 
			comment);
	String transactionIdJson = rpcClient.execute(Commands.SEND_FROM.getName(), params);
	String transactionId = rpcClient.getParser().parseString(transactionIdJson);
	return transactionId;
}
 
开发者ID:Roxas240,项目名称:CryptoPayAPI,代码行数:12,代码来源:CryptoLinkRPCImpl.java

示例6: testItem_0061

import java.math.BigDecimal; //导入方法依赖的package包/类
public void testItem_0061()
{
    BigDecimal alpha = new BigDecimal("1000").setScale(0);
    BigDecimal beta = new BigDecimal("0.70").setScale(2);
    BigDecimal gamma = alpha.divide(beta, BigDecimal.ROUND_DOWN);
    gamma.setScale(1, BigDecimal.ROUND_DOWN);
    Assert.assertEquals("1428", gamma.toString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:9,代码来源:TestSuite063.java

示例7: testItem_0036

import java.math.BigDecimal; //导入方法依赖的package包/类
public void testItem_0036()
{
    BigDecimal alpha = new BigDecimal("1000").setScale(0);
    BigDecimal beta = new BigDecimal("0.70");
    BigDecimal gamma = alpha.multiply(beta);
    gamma.setScale(2);
    Assert.assertEquals("700.00", gamma.toString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:9,代码来源:TestSuite063.java

示例8: testGetExtraFieldValues

import java.math.BigDecimal; //导入方法依赖的package包/类
@Test
public void testGetExtraFieldValues() throws IOException {
    InputStream in = new ByteArrayInputStream(MockData.MockExtraFieldsOne.getBytes(StandardCharsets.UTF_8));
    DecisionDaoProvider provider = new DecisionDaoProvider();
        
    DecisionDao d = DecisionDaoProvider.readFrom(in);
    assertTrue(d != null);
    assertTrue(!d.getExtraFieldValues().isEmpty());
   
    assertEquals(new BigDecimal(2014),d.getExtraFieldValues().get("financialYear"));
    assertEquals("Τακτικός Προϋπολογισμός",d.getExtraFieldValues().get("budgettype"));
    assertEquals("1000",d.getExtraFieldValues().get("entryNumber"));
    assertEquals(false,d.getExtraFieldValues().get("partialead"));
    Map<String,? extends Object> map = (Map<String,? extends Object>) d.getExtraFieldValues().get("amountWithVAT");
    assertEquals("EUR",map.get("currency"));
    
    List<Object> list = (List<Object>) d.getExtraFieldValues().get("amountWithKae");
    assertEquals(2,list.size());
    map = (Map<String, ?>) list.get(0);    
    assertEquals("1234",map.get("kae"));     
    BigDecimal decimal = new BigDecimal(200.231);
    decimal = decimal.setScale(3,RoundingMode.CEILING);
    assertEquals(decimal,map.get("amountWithVAT"));
    
    map = (Map<String, ?>) list.get(1);
    assertEquals("4321",map.get("kae"));
    assertEquals(new BigDecimal(300),map.get("amountWithVAT"));
    
    assertTrue(d.getExtraFieldValues().get("relatedPartialADA") == null);
    assertTrue(((List<?>)d.getExtraFieldValues().get("relatedDecisions")).isEmpty());
    assertEquals("ΠΡΑΞΗ",d.getExtraFieldValues().get("documentType"));
}
 
开发者ID:avraampiperidis,项目名称:DiavgeiaUtils,代码行数:33,代码来源:DecisionProviderReaderTest.java

示例9: testItem_0057

import java.math.BigDecimal; //导入方法依赖的package包/类
public void testItem_0057()
{
    BigDecimal alpha = new BigDecimal("1000").setScale(0);
    BigDecimal beta = new BigDecimal("0.70");
    BigDecimal gamma = alpha.divide(beta, BigDecimal.ROUND_DOWN);
    gamma.setScale(2, BigDecimal.ROUND_DOWN);
    Assert.assertEquals("1428", gamma.toString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:9,代码来源:TestSuite063.java

示例10: testItem_0049

import java.math.BigDecimal; //导入方法依赖的package包/类
public void testItem_0049()
{
    BigDecimal alpha = new BigDecimal("1000");
    BigDecimal beta = new BigDecimal("0.70");
    BigDecimal gamma = alpha.subtract(beta);
    gamma.setScale(2, BigDecimal.ROUND_DOWN);
    Assert.assertEquals("999.30", gamma.toString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:9,代码来源:TestSuite063.java

示例11: sendToAddress

import java.math.BigDecimal; //导入方法依赖的package包/类
@Override
public String sendToAddress(String toAddress, BigDecimal amount, String comment) 
		throws CryptocoinException, CommunicationException {
	amount = amount.setScale(Defaults.DECIMAL_SCALE, Defaults.ROUNDING_MODE);
	List<Object> params = CollectionUtils.asList(toAddress, amount, comment);
	String transactionIdJson = rpcClient.execute(Commands.SEND_TO_ADDRESS.getName(), params);
	String transactionId = rpcClient.getParser().parseString(transactionIdJson);
	return transactionId;
}
 
开发者ID:Roxas240,项目名称:CryptoPayAPI,代码行数:10,代码来源:CryptoLinkRPCImpl.java

示例12: testItem_0043

import java.math.BigDecimal; //导入方法依赖的package包/类
public void testItem_0043()
{
    BigDecimal alpha = new BigDecimal("1000").setScale(0);
    BigDecimal beta = new BigDecimal("0.70");
    BigDecimal gamma = alpha.add(beta);
    gamma.setScale(2, BigDecimal.ROUND_DOWN);
    Assert.assertEquals("1000.70", gamma.toString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:9,代码来源:TestSuite063.java

示例13: round

import java.math.BigDecimal; //导入方法依赖的package包/类
public static double round(double value, int places) {
	if (places < 0) throw new IllegalArgumentException();

	BigDecimal bd = new BigDecimal(value);
	bd = bd.setScale(places, RoundingMode.HALF_UP);
	return bd.doubleValue();
}
 
开发者ID:collaction,项目名称:content-farm-blocker-android,代码行数:8,代码来源:Util.java

示例14: testItem_0066

import java.math.BigDecimal; //导入方法依赖的package包/类
public void testItem_0066()
{
    BigDecimal alpha = new BigDecimal("1000").setScale(0);
    BigDecimal beta = new BigDecimal("0.70").setScale(2);
    BigDecimal gamma = alpha.multiply(beta);
    gamma.setScale(2, BigDecimal.ROUND_DOWN);
    Assert.assertEquals("700.00", gamma.toString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:9,代码来源:TestSuite063.java

示例15: decimalOp

import java.math.BigDecimal; //导入方法依赖的package包/类
@Override
public BigDecimal decimalOp() {
    BigDecimal bd = args.get(0).valDecimal();
    if (nullValue = args.get(0).isNullValue())
        return null;
    return bd.setScale(0, RoundingMode.FLOOR);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:8,代码来源:ItemFuncFloor.java


注:本文中的java.math.BigDecimal.setScale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。