Function: math[cutzeros] - cuts off trailing zeros from a float in an expression
Calling Sequence:
cutzeros(v);
Parameters:
v - any algebraic expression, a sequence, list or set or algebraic expressions
Description:
If v is of type float cutzeros deletes all trailing zeros from it - if present - and returns the shortened float.
If v is a sequence, list or set then each element k in v is checked for type float and
- if k is of type float then k is processed as described above,
- if k is not of type float it will be returned unprocessed in the result.
If v is an algebraic expression then the above algorithm is applied to each element op(n, v) in v, where n is a posint (using map ).
If a float does not have trailing zeros, it is returned as is.
If no float is found in the expression v, v is returned unprocessed.
cutzeros always returns an expression sequence in case of v being a sequence, list, or set. It returns an algebraic expression if it is passed as such.
cutzeros internally converts a float k to a string and checks each character of that string from its right to its left side for zeros. If a character char does not equal `0`, the function stops and checks whether char is the decimal point. If so, the period is omitted and the remaining string is returned as an integer using parse ; if char is not the decimal point, the remaining string is returned as a float.
This function is part of the math package, and so can be used only after performing the command with(math) or with(math, cutzeros).
Examples:
> with(math, cutzeros, makepoly):
> cutzeros(1.0000000);
> cutzeros(2.200200);
> cutzeros(1);
> poly := x^4-12*x^3+25*x+116;
> fsolve(poly, x, complex);
> makepoly({%});
> cutzeros(%);
> v := (-S[pt]-1/50-lambda-S[p])*AI[1](t)+399/25000*In(t);
> evalf(v);
> cutzeros(evalf(v));
See Also:
math/cancel , math/roundf , math/slice .
Version History:
Version 1.0 as of December 30, 1997
Version 2.0 as of February 26, 1998
Version 2.01 as of April 18, 1998
Version 2.1 as of June 06, 1998