For more information... RTFM!
NAVIGATION
RECENTLY VIEWED
ACCOUNT LOGIN

You are not logged in

Powered by Interchange version 5.7.0

round

Round the body text (assumed to be a decimal numeric value) to a given number of decimal places,

This filter takes one optional parameter.  If specified then the parameter's value will be taken to be the number of decimal places to round the number up to.

If no decimal place parameter is provided then the value of the "frac_digits" setting, in the current Locale, will be used.  If no decimal place parameter is provided, and no "frac_digits" setting exists in the current Locale, then the number of decimal places will finally default to two.

Warning

Warning

If the body text contains non-digit characters or contains more than one decimal point, then the body text will be returned verbatim.  Note that a comma is considered to be a non-digit character.

Availability

Availability

This filter was introduced in version 5.5.0, and is therefore not available for use with any earlier Interchange version.

Example

[filter round.1]123.45678[/filter]

Results in:

123.5

As warned above, this filter will fail if the input contains non-digits.  Calling the "digits_dot" filter, prior to the "round" filter, will help guard against such a failure.  For example:

[filter digits_dot round.2]abc123 def.456ghi 78[/filter]

Which would result in:

123.46

Source code

sub {
    my ($val, undef, $digits) = @_;

    return round_to_frac_digits($val, $digits);
}

Category:  Filters
Last modified by: Kevin Walsh
Modification date: Friday 23 February 2007 at 6:28 PM (EST)
Home  |  Legal nonsense  |  Privacy policy  |  Contact us