function DecimalItem::getDecimalDigits
Same name in other branches
- 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php \Drupal\Core\Field\Plugin\Field\FieldType\DecimalItem::getDecimalDigits()
- 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php \Drupal\Core\Field\Plugin\Field\FieldType\DecimalItem::getDecimalDigits()
- 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php \Drupal\Core\Field\Plugin\Field\FieldType\DecimalItem::getDecimalDigits()
Helper method to get the number of decimal digits out of a decimal number.
Parameters
int $decimal: The number to calculate the number of decimals digits from.
Return value
int The number of decimal digits.
1 call to DecimalItem::getDecimalDigits()
- DecimalItem::generateSampleValue in core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ DecimalItem.php - Generates placeholder field values.
File
-
core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ DecimalItem.php, line 153
Class
- DecimalItem
- Defines the 'decimal' field type.
Namespace
Drupal\Core\Field\Plugin\Field\FieldTypeCode
protected static function getDecimalDigits($decimal) {
$digits = 0;
while ($decimal - round($decimal)) {
$decimal *= 10;
$digits++;
}
return $digits;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.