ICU 56.1: icu::ScientificNumberFormatter Class Reference

ICU 56.1 56.1

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

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

Data Structures | Public Member Functions | Static Public Member Functions
icu::ScientificNumberFormatter Class Reference

A formatter that formats numbers in user-friendly scientific notation. More...

`#include <scientificnumberformatter.h>`

Inheritance diagram for icu::ScientificNumberFormatter:

## Public Member Functions
ScientificNumberFormatter * | clone () const
| Returns a copy of this object. More...
virtual | ~ScientificNumberFormatter ()
| Destructor. More...
UnicodeString & | format (const Formattable &number, UnicodeString &appendTo, UErrorCode &status) const
| Formats a number into user friendly scientific notation. More...
Public Member Functions inherited from icu::UObject
virtual | ~UObject ()
| Destructor. More...
virtual UClassID | getDynamicClassID () const
| ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class. More...

## Static Public Member Functions
static ScientificNumberFormatter * | createSuperscriptInstance (DecimalFormat *fmtToAdopt, UErrorCode &status)
| Creates a ScientificNumberFormatter instance that uses superscript characters for exponents. More...
static ScientificNumberFormatter * | createSuperscriptInstance (const Locale &locale, UErrorCode &status)
| Creates a ScientificNumberFormatter instance that uses superscript characters for exponents for this locale. More...
static ScientificNumberFormatter * | createMarkupInstance (DecimalFormat *fmtToAdopt, const UnicodeString &beginMarkup, const UnicodeString &endMarkup, UErrorCode &status)
| Creates a ScientificNumberFormatter instance that uses markup for exponents. More...
static ScientificNumberFormatter * | createMarkupInstance (const Locale &locale, const UnicodeString &beginMarkup, const UnicodeString &endMarkup, UErrorCode &status)
| Creates a ScientificNumberFormatter instance that uses markup for exponents for this locale. More...

## Detailed Description

A formatter that formats numbers in user-friendly scientific notation.

Sample code:

    UErrorCode status = U_ZERO_ERROR;
    LocalPointer<ScientificNumberFormatter> fmt(
            ScientificNumberFormatter::createMarkupInstance(
                    "en", "<sup>", "</sup>", status));
    if (U_FAILURE(status)) {
        return;
    }
    UnicodeString appendTo;
    // appendTo = "1.23456x10<sup>-78</sup>"
    fmt->format(1.23456e-78, appendTo, status);

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

Definition at line 50 of file scientificnumberformatter.h.

## Constructor & Destructor Documentation

virtual icu::ScientificNumberFormatter::~ScientificNumberFormatter | ( |  | ) |
| virtual

Destructor.

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

## Member Function Documentation

ScientificNumberFormatter* icu::ScientificNumberFormatter::clone | ( | void |  | ) | const
| inline

Returns a copy of this object.

Caller must free returned copy.

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

Definition at line 119 of file scientificnumberformatter.h.

static ScientificNumberFormatter* icu::ScientificNumberFormatter::createMarkupInstance | ( | DecimalFormat * | fmtToAdopt,
|  | const UnicodeString & | beginMarkup,
|  | const UnicodeString & | endMarkup,
|  | UErrorCode & | status
| ) |  |
| static

Creates a ScientificNumberFormatter instance that uses markup for exponents.

Parameters

  fmtToAdopt | The DecimalFormat which must be configured for scientific notation.
  beginMarkup | the markup to start superscript.
  endMarkup | the markup to end superscript.
  status | error returned here.

Returns
  The new ScientificNumberFormatter instance.

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

static ScientificNumberFormatter* icu::ScientificNumberFormatter::createMarkupInstance | ( | const Locale & | locale,
|  | const UnicodeString & | beginMarkup,
|  | const UnicodeString & | endMarkup,
|  | UErrorCode & | status
| ) |  |
| static

Creates a ScientificNumberFormatter instance that uses markup for exponents for this locale.

Parameters

  locale | The locale
  beginMarkup | the markup to start superscript.
  endMarkup | the markup to end superscript.
  status | error returned here.

Returns
  The ScientificNumberFormatter instance.

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

static ScientificNumberFormatter* icu::ScientificNumberFormatter::createSuperscriptInstance | ( | DecimalFormat * | fmtToAdopt,
|  | UErrorCode & | status
| ) |  |
| static

Creates a ScientificNumberFormatter instance that uses superscript characters for exponents.

Parameters

  fmtToAdopt | The DecimalFormat which must be configured for scientific notation.
  status | error returned here.

Returns
  The new ScientificNumberFormatter instance.

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

static ScientificNumberFormatter* icu::ScientificNumberFormatter::createSuperscriptInstance | ( | const Locale & | locale,
|  | UErrorCode & | status
| ) |  |
| static

Creates a ScientificNumberFormatter instance that uses superscript characters for exponents for this locale.

Parameters

  locale | The locale
  status | error returned here.

Returns
  The ScientificNumberFormatter instance.

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

UnicodeString& icu::ScientificNumberFormatter::format | ( | const Formattable & | number,
|  | UnicodeString & | appendTo,
|  | UErrorCode & | status
| ) |  | const

Formats a number into user friendly scientific notation.

Parameters

  number | the number to format.
  appendTo | formatted string appended here.
  status | any error returned here.

Returns
  appendTo

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

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

- scientificnumberformatter.h