How would I represent mathematical expressions in Java
I am 开发者_如何学Gotrying to type the following sentence in the Eclipse editor 8.0 × 10 power 4 - But I am unable to get 4 represented properly, how should I do that?
Judging by your comment on a previous answer, it sounds like you're trying to write the expression like this:
8.0 x 104
The 4 is in superscript - and unless the editor has support for putting text in super/subscript you can't do it without copying and pasting the unicode character representation for superscript 4. (Note, copying the 4 from this example will not give you a superscript 4.)
In HTML (which is how I wrote this here) you would use the <sup>
tag.
Generally, when powers are written in plain text, the ^ symbol is used to denote that it is a power, like this:
8.0 x 10^4
8 * Math.pow(10, 4)
精彩评论