# Revision history [back]

Is there any way to split up a symbolic expression like '25*degree' into units and value? some function like:

sage: t = 25*degree;

sage: units(t)

degree

sage: float(t/units(t))

25.0

This will make possible the usage of all functions, designed for numeric arguments, with units of measurement. BTW, the expression t(1) gives the desired value, however, this is deprecated and will not work with multiple units product.

Is there any way to split up a symbolic expression like '25*degree' into units and value? some function like:

sage: t = 25*degree;25*units.angles.degree;

sage: units(t)

degree

sage: float(t/units(t))

25.0

This will make possible the usage of all functions, designed for numeric arguments, with units of measurement. BTW, the expression t(1) gives the desired value, however, this is deprecated and will not work with multiple units product.

Is there any way to split up a symbolic expression like '25*degree' into units and value? some function like:

sage: t = 25*units.angles.degree; 25*units.angles.degree;
sage: units(t) degree get_numeric(t)
25.0
sage: float(t/units(t)) 25.0t/get_numeric(t)
degree


This will make possible the usage of all functions, designed for numeric arguments, with units of measurement. BTW, measurement,after some simple redefinition. As the expression t(1) gives the desired value, however, this is deprecated and will not units work with multiple units product.like symbolic variables, we can set them to ones to get a numerical value:

sage: float(t(units.angles.degree=1))
25.0


For that, one has to know the units involved. it can be achieved by arguments() function:

sage: t.arguments()
(degree,)


Unfortunately, I do not know yet how to put all of that together. And about the performance of such method.

Is there any way to split up a symbolic expression like '25*degree' into units and value? some function like:

sage: t = 25*units.angles.degree;
sage: get_numeric(t)
25.0
sage: t/get_numeric(t)
degree


This will make possible the usage of all functions, designed for numeric arguments, with units of measurement,after some simple redefinition. As the units work like symbolic variables, we can set them to ones unity to get a numerical value:

sage: float(t(units.angles.degree=1))
25.0


For that, one has to know the units involved. it can be achieved by arguments() function:

sage: t.arguments()
(degree,)


Unfortunately, I do not Putting all together:

def get_numeric(t)
dic={};
for arg in t.arguments():
dic[arg]=1;
return (float(t(dic)));


Don't know yet how to put all of that together. And about the performance of such method.