I am new to Java and I’m not quite sure how to output an integer raised to a power as a string output. I know that
Math.pow(double, double)
will actually compute the value of raising a double to a power. But if I wanted to output “2^6” as an output (except with 6 as a superscript and not with the carat), how do I do that?
EDIT: This is for an Android app. I’m passing in the integer raised to the power as a string and I would like to know how to convert this to superscript in the UI for the phone.
If you’re outputting the text to the GUI then you can use HTML formatting and the
<sup>tag to get a superscript. Otherwise, you’ll have to use Unicode characters to get the other superscripts. Wikipedia has a nice article on superscripts and subscripts in Unicode:http://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts