This question already has answers here:
Subscript and Superscript a String in Android
(15 answers)
Closed 9 years ago.
Is it possible to display 2, 3 etc raised as you would when working with maths equations?
Like this
Html.fromHtml("2"+"<sup>-2</sup>");
//shows 2 raised to -2
similarly use
<sub> x</sub>
tag for subscript
KISS. Use unicode superscripts... unless your font do not contains them of course.
Related
This question already has answers here:
How can I pad an integer with zeros on the left?
(18 answers)
Closed 5 years ago.
What does it represents in java?
String.format("%01000d",0)
It prints 0 thousands times. But can anyone help how does it actually works. What does "%01000d" represents?
The first argument is a format string, here you can find the sintax:
https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax
This question already has answers here:
Large Numbers in Java
(6 answers)
Closed 6 years ago.
given here only as a form of validating.Which data type to use to store such a big number
Probably what you're looking for is BigInteger, BigDecimal if you want decimals instead.
This question already has answers here:
Double parameter with 2 digits after dot in strings.xml?
(7 answers)
Closed 7 years ago.
Currently in my strings.xml I have
`<string name="price_string">My string with price: %1$s</string>`
The problem with this is it outputs 5, instead of 5.5. How would I format it to include up to 2 decimals?
<string name="price_string">My string with price: %0.2f$s</string>`
This question already has answers here:
Subscript and Superscript a String in Android
(15 answers)
Closed 8 years ago.
I am writing a simple android app and I would like to set the text of a button to be X^n but I want it to look the same way as it would if you would write it on a piece of paper( for example 2⁶).
I know there are several unicode characters that does it for a small group of numbers but I am looking for a generel function (or any other way) that takes two integers and output the first by the power of the second. For example:
int X=2;
int n=6;
function(X , n) ==> 2⁶
I know a similar question was asked here before but its answers were not sufficient because I want to use variables' values and not actual numbers;
Thanks!
You can use html's <sup> tags for that:
button.setText(Html.fromHtml("X<sup>n</sup>"));
This question already has answers here:
Is floating point math broken?
(31 answers)
Floating point multiplication in java [duplicate]
(3 answers)
Closed 8 years ago.
Ok, so i made a scientific calculator recently and one of my friends was using it when he said that if he types in (2.1 * 3) the answer should be 6.3 but he recieves something like: 6.30000001.
Why does this happen?
Is this some sort of bug in java?
EDIT: Its not just a problem with my calc, i also made a small java file for multiplying 2 numbers and i face the same probelem even in cmd