You are here

function fraction_from_decimal in Fraction 7

Same name and namespace in other branches
  1. 8 fraction.module \fraction_from_decimal()
  2. 2.x fraction.module \fraction_from_decimal()

Convert a decimal value into a fraction object.

Parameters

$value: The decimal value to be converted.

Return value

\Fraction Returns a new fraction object.

4 calls to fraction_from_decimal()
FractionEntityTestCase::testEntityIntegration in ./fraction.test
fraction_feeds_set_target in ./fraction.feeds.inc
Callback for mapping fraction fields in Feeds.
fraction_field_presave in ./fraction.field.inc
Implements hook_field_presave().
_fraction_decimal_widget_validate in ./fraction.field.inc
Validation function for the fraction_decimal widget to convert the decimal to a fraction.

File

./fraction.module, line 53
Fraction

Code

function fraction_from_decimal($value) {
  return fraction()
    ->fromDecimal($value);
}