Convert[0.05263, Percent] /. Percent -> "%"

I would like to remove the trailing "%" but if I put Percent->"" it concatenates a literal empty pair of quotes.


Edit: I should have explained it works well in the Mathematica interactive evaluator but not in an InputField where it will concatenate the said quotes.

  • $\begingroup$ Convert does not appear to be a built-in Mathematica function. Are you using a package where Convert is defined? $\endgroup$
    – DavidC
    Commented Apr 26, 2013 at 12:25
  • $\begingroup$ Perhaps pre-9 Units package? $\endgroup$
    – cormullion
    Commented Apr 26, 2013 at 12:33
  • $\begingroup$ Yes I am using Units. So my code has a Needs["Units`"]. I am using Mathematica 9. $\endgroup$
    – dabd
    Commented Apr 26, 2013 at 12:36

2 Answers 2


For the older "Units`" package units are just symbols which are multiplied to numbers. If you want to get rid of them, just replace them with 1:

 Convert[0.05263, Percent] /. Percent -> 1

In such cases, it is often very useful to use InputForm or even FullForm to explicitly check with what you are dealing and what is returned, e.g.:

 Convert[0.05263, Percent] /. Percent -> 1 // FullForm

which shows that now the number is all that's left, without any spurious relicts of the former units caculation...


You can the following to check the FullForm of your code (makes it easy to understand how Mathematica's internal structures works. Check Mathematica's reference if you want to know details about this.

FullForm[Convert[0.05263, Percent]]
(* Result: Times[5.263`,Percent] *)

There you see that it is a simple multiplication (Head: Times) of two elements. Then you can either use Albert Retey's solution or do a simple

First[Convert[0.05263, Percent]]
(* Result: 5.263 *)

This is especially usefull if you have a more complex output like

(* Result: Times[299792458,Meter,Power[Second,-1]] *)

Then you can do a quick

(* Result: 299792458 *)

to get the value of this expression without the units.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.