ICU 54.1 54.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Data Structure Index
- Class Hierarchy
- Data Fields

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
icu::ScientificFormatHelper Class Reference

A helper class for formatting numbers in standard scientific notation instead of E notation. More...

`#include <scientificformathelper.h>`

Inheritance diagram for icu::ScientificFormatHelper:

## Public Member Functions
| ScientificFormatHelper (const DecimalFormatSymbols &symbols, UErrorCode &status)
| Constructor.
| ScientificFormatHelper (const ScientificFormatHelper &other)
| Copy constructor.
ScientificFormatHelper & | operator= (const ScientificFormatHelper &other)
| Assignment operator.
virtual | ~ScientificFormatHelper ()
| Destructor.
UnicodeString & | insertMarkup (const UnicodeString &s, FieldPositionIterator &fpi, const UnicodeString &beginMarkup, const UnicodeString &endMarkup, UnicodeString &result, UErrorCode &status) const
| Formats standard scientific notation by surrounding exponent with html to make it superscript.
UnicodeString & | toSuperscriptExponentDigits (const UnicodeString &s, FieldPositionIterator &fpi, UnicodeString &result, UErrorCode &status) const
| Formats standard scientific notation by using superscript unicode points 0..9.
Public Member Functions inherited from icu::UObject
virtual | ~UObject ()
| Destructor.
virtual UClassID | getDynamicClassID () const
| ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.

## Detailed Description

A helper class for formatting numbers in standard scientific notation instead of E notation.

Sample code:

    UErrorCode status = U_ZERO_ERROR;
    DecimalFormat *decfmt = (DecimalFormat *)
        NumberFormat::createScientificInstance("en", status);
    UnicodeString appendTo;
    FieldPositionIterator fpositer;
    decfmt->format(1.23456e-78, appendTo, &fpositer, status);
    ScientificFormatHelper helper(*decfmt->getDecimalFormatSymbols(), status);
    UnicodeString result;

    // result = "1.23456x10<sup>-78</sup>"
    helper.insertMarkup(appendTo, fpositer, "<sup>", "</sup>", result, status));

See Also
  NumberFormat

Draft:
  This API may be changed in the future versions and was introduced in ICU 54

Definition at line 51 of file scientificformathelper.h.

## Constructor & Destructor Documentation

icu::ScientificFormatHelper::ScientificFormatHelper | ( | const DecimalFormatSymbols & | symbols,
|  | UErrorCode & | status
| ) |  |

Constructor.

Parameters

  symbols | comes from DecimalFormat instance used for default scientific notation.
  status | any error reported here.

Draft:
  This API may be changed in the future versions and was introduced in ICU 54

icu::ScientificFormatHelper::ScientificFormatHelper | ( | const ScientificFormatHelper & | other | ) |

Copy constructor.

Draft:
  This API may be changed in the future versions and was introduced in ICU 54

virtual icu::ScientificFormatHelper::~ScientificFormatHelper | ( |  | ) |
| virtual

Destructor.

Draft:
  This API may be changed in the future versions and was introduced in ICU 54

## Member Function Documentation

UnicodeString& icu::ScientificFormatHelper::insertMarkup | ( | const UnicodeString & | s,
|  | FieldPositionIterator & | fpi,
|  | const UnicodeString & | beginMarkup,
|  | const UnicodeString & | endMarkup,
|  | UnicodeString & | result,
|  | UErrorCode & | status
| ) |  | const

Formats standard scientific notation by surrounding exponent with html to make it superscript.

Parameters

  s | the original formatted scientific notation e.g "6.02e23". s is output from NumberFormat::createScientificInstance()->format().
  fpi | the FieldPositionIterator from the format call. fpi is output from NumberFormat::createScientificInstance()->format().
  beginMarkup | the start html for the exponent e.g "<sup>"
  endMarkup | the end html for the exponent e.g "</sup>"
  result | standard scientific notation appended here.
  status | any error returned here. When status is set to a non-zero error, the value of result is unspecified, and client should fallback to using s for scientific notation.

Returns
  the value stored in result.

Draft:
  This API may be changed in the future versions and was introduced in ICU 54

ScientificFormatHelper& icu::ScientificFormatHelper::operator= | ( | const ScientificFormatHelper & | other | ) |

Assignment operator.

Draft:
  This API may be changed in the future versions and was introduced in ICU 54

UnicodeString& icu::ScientificFormatHelper::toSuperscriptExponentDigits | ( | const UnicodeString & | s,
|  | FieldPositionIterator & | fpi,
|  | UnicodeString & | result,
|  | UErrorCode & | status
| ) |  | const

Formats standard scientific notation by using superscript unicode points 0..9.

Parameters

  s | the original formatted scientific notation e.g "6.02e23". s is output from NumberFormat::createScientificInstance()->format().
  fpi | the FieldPositionIterator from the format call. fpi is output from NumberFormat::createScientificInstance()->format().
  result | standard scientific notation appended here.
  status | any error returned here. When status is set to a non-zero error, the value of result is unspecified, and client should fallback to using s for scientific notation.

Returns
  the value stored in result.

Draft:
  This API may be changed in the future versions and was introduced in ICU 54

The documentation for this class was generated from the following file:

- scientificformathelper.h