Search in sources :

Example 1 with ScientificNumberFormatter

use of android.icu.text.ScientificNumberFormatter in project j2objc by google.

the class ScientificNumberFormatterTest method TestFarsi.

@Test
public void TestFarsi() {
    ScientificNumberFormatter fmt = ScientificNumberFormatter.getMarkupInstance(new ULocale("fa"), "<sup>", "</sup>");
    assertEquals("", "۱٫۲۳۴۵۶×۱۰<sup>‎−۷۸</sup>", fmt.format(1.23456e-78));
}
Also used : ULocale(android.icu.util.ULocale) ScientificNumberFormatter(android.icu.text.ScientificNumberFormatter) Test(org.junit.Test)

Example 2 with ScientificNumberFormatter

use of android.icu.text.ScientificNumberFormatter in project j2objc by google.

the class ScientificNumberFormatterTest method TestBasic.

@Test
public void TestBasic() {
    ScientificNumberFormatter markup = ScientificNumberFormatter.getMarkupInstance(ULocale.ENGLISH, "<sup>", "</sup>");
    ScientificNumberFormatter superscript = ScientificNumberFormatter.getSuperscriptInstance(ULocale.ENGLISH);
    assertEquals("toMarkupExponentDigits", "1.23456×10<sup>-78</sup>", markup.format(1.23456e-78));
    assertEquals("toSuperscriptExponentDigits", "1.23456×10⁻⁷⁸", superscript.format(1.23456e-78));
}
Also used : ScientificNumberFormatter(android.icu.text.ScientificNumberFormatter) Test(org.junit.Test)

Example 3 with ScientificNumberFormatter

use of android.icu.text.ScientificNumberFormatter in project j2objc by google.

the class ScientificNumberFormatterTest method TestFixedDecimalSuperscript.

@Test
public void TestFixedDecimalSuperscript() {
    DecimalFormat decfmt = (DecimalFormat) NumberFormat.getInstance(ULocale.ENGLISH);
    ScientificNumberFormatter fmt = ScientificNumberFormatter.getSuperscriptInstance(decfmt);
    assertEquals("", "123,456", fmt.format(123456.0));
}
Also used : DecimalFormat(android.icu.text.DecimalFormat) ScientificNumberFormatter(android.icu.text.ScientificNumberFormatter) Test(org.junit.Test)

Example 4 with ScientificNumberFormatter

use of android.icu.text.ScientificNumberFormatter in project j2objc by google.

the class ScientificNumberFormatterTest method TestPlusSignInExponentMarkup.

@Test
public void TestPlusSignInExponentMarkup() {
    DecimalFormat decfmt = (DecimalFormat) NumberFormat.getScientificInstance(ULocale.ENGLISH);
    decfmt.applyPattern("0.00E+0");
    ScientificNumberFormatter fmt = ScientificNumberFormatter.getMarkupInstance(decfmt, "<sup>", "</sup>");
    assertEquals("", "6.02×10<sup>+23</sup>", fmt.format(6.02e23));
}
Also used : DecimalFormat(android.icu.text.DecimalFormat) ScientificNumberFormatter(android.icu.text.ScientificNumberFormatter) Test(org.junit.Test)

Example 5 with ScientificNumberFormatter

use of android.icu.text.ScientificNumberFormatter in project j2objc by google.

the class ScientificNumberFormatterTest method TestPlusSignInExponentSuperscript.

@Test
public void TestPlusSignInExponentSuperscript() {
    DecimalFormat decfmt = (DecimalFormat) NumberFormat.getScientificInstance(ULocale.ENGLISH);
    decfmt.applyPattern("0.00E+0");
    ScientificNumberFormatter fmt = ScientificNumberFormatter.getSuperscriptInstance(decfmt);
    assertEquals("", "6.02×10⁺²³", fmt.format(6.02e23));
}
Also used : DecimalFormat(android.icu.text.DecimalFormat) ScientificNumberFormatter(android.icu.text.ScientificNumberFormatter) Test(org.junit.Test)

Aggregations

ScientificNumberFormatter (android.icu.text.ScientificNumberFormatter)6 Test (org.junit.Test)6 DecimalFormat (android.icu.text.DecimalFormat)4 ULocale (android.icu.util.ULocale)1