For more information on Double, see Primitive Data Types.
The following are methods for Double.
public String format()
Type: String
Double myDouble = 1261992; system.assertEquals('1,261,992', myDouble.format());
public Integer intValue()
Type: Integer
Double DD1 = double.valueOf('3.14159'); Integer value = DD1.intValue(); system.assertEquals(value, 3);
public Long longValue()
Type: Long
Double myDouble = 421994; Long value = myDouble.longValue(); System.assertEquals(421994, value);
public Long round()
Type: Long
Double D1 = 4.5; Long L1 = D1.round(); System.assertEquals(5, L1); Double D2= 4.2; Long L2= D2.round(); System.assertEquals(4, L2); Double D3= -4.7; Long L3= D3.round(); System.assertEquals(-5, L3);
public static Double valueOf(String stringToDouble)
Type: Double
Double DD1 = double.valueOf('3.14159');
public static Double valueOf(Object fieldValue)
Type: Double
Use this method with the OldValue or NewValue fields of history sObjects, such as AccountHistory, when the field type corresponds to a Double type, like a number field.
List<AccountHistory> ahlist = [SELECT Field,OldValue,NewValue FROM AccountHistory]; for(AccountHistory ah : ahlist) { System.debug('Field: ' + ah.Field); if (ah.field == 'NumberOfEmployees') { Double oldValue = Double.valueOf(ah.OldValue); Double newValue = Double.valueOf(ah.NewValue); }