54、salesforce学习笔记(一)

Decimal priceDecimal = -4.50;
System.debug('小数的绝对值为:'+priceDecimal.abs());

System.debug('priceDecimal除以10小数点保留两位小数:'+ priceDecimal.divide(10,2));

System.debug('将priceDecimal转换成Double类型'+priceDecimal.doubleValue());

System.debug('Decimal转成String类型'+priceDecimal.format());

System.debug('将Decimal转成Integer类型'+priceDecimal.intValue());

System.debug('将Decimal转成Long类型'+priceDecimal.longValue());

System.debug('priceDecimal平方值为:'+priceDecimal.pow(2));

System.debug('priceDecimal数字总数为:'+priceDecimal.precision());

System.debug('priceDecimal四舍五入Long类型值为:'+priceDecimal.round());

System.debug('priceDeciaml的小数为2位'+priceDecimal.setScale(2));

System.debug('移出priceDecimal小数点后的0以后的值为:'+priceDecimal.stripTrailingZeros());

System.debug('不使用科学计数法转换成String类型'+priceDecimal.toPlainString());

Long priceL = 12345;
Double priceD = 123.456;
String priceS = '12345';
Decimal d1 = Decimal.valueOf(priceL);
Decimal d2 = Decimal.valueOf(priceD);
Decimal d3 = Decimal.valueOf(priceS);

 

Double

Double price = 34.5678;
String doubleString = '3.89';
System.debug('将字符串转换成Double'+Double.valueOf(doubleString));

Long priceLong = price.round();
System.debug('通过round方法将double转换成Long类型值为:'+priceLong);

Integer priceInteger = price.intValue();
System.debug('将double转换成Integer类型值为:'+priceInteger);

Long priceLongByLongValue = price.longValue();
System.debug('将double转换成Long类型值为:'+priceLongByLongValue);

 

posted @ 2017-02-09 17:25  香港胖仔  阅读(602)  评论(0编辑  收藏  举报