54、salesforce学习笔记(一)

来源:互联网 发布:软件原型制作工具 编辑:程序博客网 时间:2024/06/07 02:30
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);

 

阅读全文
0 0
原创粉丝点击