954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

printing powers in java

if i want to print 2 to the power 3 normally what we do is 2^3. is there any other way that i can print it in the console in the way that we normally write it on a paper.
does anyone know it pls tell me.

smsamrc
Newbie Poster
11 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

Yes, read it in as a String and print it out. ?

BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
 
Yes, read it in as a String and print it out. ?

Actually whatsmsamrc is asking is to print at the console something like this:

To have 2 as base and 3 to be smaller and to the upper right corner of 2.

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 
LevelSix
Junior Poster in Training
59 posts since May 2008
Reputation Points: 22
Solved Threads: 3
 

Actually what smsamrc is asking is to print at the console something like this:

To have 2 as base and 3 to be smaller and to the upper right corner of 2.


Oops. I understand now.

BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
 
So, a superscript? http://java.sun.com/j2se/1.4.2/docs/api/java/awt/font/TextAttribute.html May be of use.

Do they work in the console? I suspect not. You could use the unicode symbols for ² or ³ (00B2 and 00B3), but that's all, I think.
In JLabels and the like you can use HTML formatting, of course.

JamesCherrill
Posting Genius
Moderator
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

thank you for ur hints.

smsamrc
Newbie Poster
11 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You