Top Description Inners Fields Constructors Methods
com.ibm.icu.number

public Class ScientificNotation

extends Notation
Class Inheritance
Imports
java.text.Format.Field, com.ibm.icu.impl.FormattedStringBuilder, com.ibm.icu.impl.number.ConstantAffixModifier, .DecimalQuantity, .MicroProps, .MicroPropsGenerator, .Modifier, .MultiplierProducer, .RoundingUtils, com.ibm.icu.number.NumberFormatter.SignDisplay, .Precision.SignificantRounderImpl, com.ibm.icu.text.DecimalFormatSymbols, .NumberFormat

A class that defines the scientific notation style to be used when formatting numbers in NumberFormatter.

To create a ScientificNotation, use one of the factory methods in Notation.

ICU Status
Stable since ICU 60.
See Also
NumberFormatter

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv NumberFormatter.SignDisplay
pack-priv int
pack-priv boolean

Constructor Summary

AccessConstructor and Description
pack-priv
ScientificNotation(int engineeringInterval, boolean requireMinInt, int minExponentDigits, NumberFormatter.SignDisplay exponentSignDisplay)

Method Summary

Modifier and TypeMethod and Description
pack-priv ScientificNotation
createCopy()

Package-private clone method

public ScientificNotation

Returns:

A ScientificNotation, for chaining.
withExponentSignDisplay
(NumberFormatter.SignDisplay
The strategy for displaying the sign in the exponent.
exponentSignDisplay
)

Sets whether to show the sign on positive and negative exponents in scientific notation.

pack-priv MicroPropsGenerator
public ScientificNotation

Returns:

A ScientificNotation, for chaining.
withMinExponentDigits
(int
The minimum number of digits to show in the exponent.
minExponentDigits
)

Sets the minimum number of digits to show in the exponent of scientific notation, padding with zeros if necessary.

Inherited from com.ibm.icu.number.Notation:
compactLongcompactShortengineeringscientificsimple

Field Detail

engineeringIntervalback to summary
pack-priv int engineeringInterval
exponentSignDisplayback to summary
pack-priv NumberFormatter.SignDisplay exponentSignDisplay
minExponentDigitsback to summary
pack-priv int minExponentDigits
requireMinIntback to summary
pack-priv boolean requireMinInt

Constructor Detail

ScientificNotationback to summary
pack-priv ScientificNotation(int engineeringInterval, boolean requireMinInt, int minExponentDigits, NumberFormatter.SignDisplay exponentSignDisplay)

Method Detail

createCopyback to summary
pack-priv ScientificNotation createCopy()

Package-private clone method

withExponentSignDisplayback to summary
public ScientificNotation withExponentSignDisplay(NumberFormatter.SignDisplay exponentSignDisplay)

Sets whether to show the sign on positive and negative exponents in scientific notation. The default is AUTO, showing the minus sign but not the plus sign.

For example, with exponentSignDisplay=ALWAYS, the number 123 will be printed as "1.23E+2" in en-US instead of the default "1.23E2".

Parameters
exponentSignDisplay:NumberFormatter.SignDisplay

The strategy for displaying the sign in the exponent.

Returns:ScientificNotation

A ScientificNotation, for chaining.

ICU Status
Stable since ICU 60.
See Also
NumberFormatter
withLocaleDataback to summary
pack-priv MicroPropsGenerator withLocaleData(DecimalFormatSymbols symbols, boolean build, MicroPropsGenerator parent)
withMinExponentDigitsback to summary
public ScientificNotation withMinExponentDigits(int minExponentDigits)

Sets the minimum number of digits to show in the exponent of scientific notation, padding with zeros if necessary. Useful for fixed-width display.

For example, with minExponentDigits=2, the number 123 will be printed as "1.23E02" in en-US instead of the default "1.23E2".

Parameters
minExponentDigits:int

The minimum number of digits to show in the exponent.

Returns:ScientificNotation

A ScientificNotation, for chaining.

Exceptions
IllegalArgumentException:
if minExponentDigits is too big or smaller than 1
ICU Status
Stable since ICU 60.
See Also
NumberFormatter
com.ibm.icu.number back to summary

private Class ScientificNotation.ScientificHandler

extends Object
implements MicroPropsGenerator, MultiplierProducer, Modifier
Class Inheritance
All Implemented Interfaces
com.ibm.icu.impl.number.Modifier, com.ibm.icu.impl.number.MultiplierProducer, com.ibm.icu.impl.number.MicroPropsGenerator

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv final ScientificNotation
pack-priv final MicroPropsGenerator
pack-priv final ScientificNotation.ScientificModifier[]
pack-priv final DecimalFormatSymbols

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
apply(FormattedStringBuilder
The string builder to which to apply this modifier.
output
,
int
The left index of the string within the builder. Equal to 0 when only one number is being formatted.
leftIndex
,
int
The right index of the string within the string builder. Equal to length when only one number is being formatted.
rightIndex
)

Implements com.ibm.icu.impl.number.Modifier.apply.

Apply this Modifier to the string builder.
public boolean
containsField(Format.Field field)

Implements com.ibm.icu.impl.number.Modifier.containsField.

Whether the modifier contains at least one occurrence of the given field.
private int
doApply(int exponent, FormattedStringBuilder output, int rightIndex)

public int
getCodePointCount()

Implements com.ibm.icu.impl.number.Modifier.getCodePointCount.

Returns the number of code points in the modifier, prefix plus suffix.
public int
getMultiplier(int
The power of ten of the input number.
magnitude
)

Implements com.ibm.icu.impl.number.MultiplierProducer.getMultiplier.

Maps a magnitude to a multiplier in powers of ten.
public Modifier.Parameters
getParameters()

Implements com.ibm.icu.impl.number.Modifier.getParameters.

Gets a set of "parameters" for this Modifier.
public int
getPrefixLength()

Implements com.ibm.icu.impl.number.Modifier.getPrefixLength.

Gets the length of the prefix.
public boolean
isStrong()

Implements com.ibm.icu.impl.number.Modifier.isStrong.

Whether this modifier is strong.
public MicroProps
processQuantity(DecimalQuantity
The quantity for consideration and optional mutation.
quantity
)

Implements com.ibm.icu.impl.number.MicroPropsGenerator.processQuantity.

Deprecated as a consequence of DecimalQuantity being deprecated.
Considers the given DecimalQuantity, optionally mutates it, and returns a MicroProps.
public boolean
semanticallyEquivalent(Modifier other)

Implements com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

Returns whether this Modifier is *semantically equivalent* to the other Modifier; in many cases, this is the same as equal, but parameters should be ignored.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

exponentback to summary
pack-priv int exponent
notationback to summary
pack-priv final ScientificNotation notation
parentback to summary
pack-priv final MicroPropsGenerator parent
precomputedModsback to summary
pack-priv final ScientificNotation.ScientificModifier[] precomputedMods
symbolsback to summary
pack-priv final DecimalFormatSymbols symbols

Constructor Detail

ScientificHandlerback to summary
private ScientificHandler(ScientificNotation notation, DecimalFormatSymbols symbols, boolean safe, MicroPropsGenerator parent)

Method Detail

applyback to summary
public int apply(FormattedStringBuilder output, int leftIndex, int rightIndex)

Implements com.ibm.icu.impl.number.Modifier.apply.

Doc from com.ibm.icu.impl.number.Modifier.apply.

Apply this Modifier to the string builder.

Parameters
output:FormattedStringBuilder

The string builder to which to apply this modifier.

leftIndex:int

The left index of the string within the builder. Equal to 0 when only one number is being formatted.

rightIndex:int

The right index of the string within the string builder. Equal to length when only one number is being formatted.

Returns:int

The number of characters (UTF-16 code units) that were added to the string builder.

Annotations
@Override
containsFieldback to summary
public boolean containsField(Format.Field field)

Implements com.ibm.icu.impl.number.Modifier.containsField.

Doc from com.ibm.icu.impl.number.Modifier.containsField.

Whether the modifier contains at least one occurrence of the given field.

Annotations
@Override
doApplyback to summary
private int doApply(int exponent, FormattedStringBuilder output, int rightIndex)
getCodePointCountback to summary
public int getCodePointCount()

Implements com.ibm.icu.impl.number.Modifier.getCodePointCount.

Doc from com.ibm.icu.impl.number.Modifier.getCodePointCount.

Returns the number of code points in the modifier, prefix plus suffix.

Annotations
@Override
getMultiplierback to summary
public int getMultiplier(int magnitude)

Implements com.ibm.icu.impl.number.MultiplierProducer.getMultiplier.

Doc from com.ibm.icu.impl.number.MultiplierProducer.getMultiplier.

Maps a magnitude to a multiplier in powers of ten. For example, in compact notation in English, a magnitude of 5 (e.g., 100,000) should return a multiplier of -3, since the number is displayed in thousands.

Parameters
magnitude:int

The power of ten of the input number.

Returns:int

The shift in powers of ten.

Annotations
@Override
getParametersback to summary
public Modifier.Parameters getParameters()

Implements com.ibm.icu.impl.number.Modifier.getParameters.

Doc from com.ibm.icu.impl.number.Modifier.getParameters.

Gets a set of "parameters" for this Modifier.

Annotations
@Override
getPrefixLengthback to summary
public int getPrefixLength()

Implements com.ibm.icu.impl.number.Modifier.getPrefixLength.

Doc from com.ibm.icu.impl.number.Modifier.getPrefixLength.

Gets the length of the prefix. This information can be used in combination with apply to extract the prefix and suffix strings.

Returns:int

The number of characters (UTF-16 code units) in the prefix.

Annotations
@Override
isStrongback to summary
public boolean isStrong()

Implements com.ibm.icu.impl.number.Modifier.isStrong.

Doc from com.ibm.icu.impl.number.Modifier.isStrong.

Whether this modifier is strong. If a modifier is strong, it should always be applied immediately and not allowed to bubble up. With regard to padding, strong modifiers are considered to be on the inside of the prefix and suffix.

Returns:boolean

Whether the modifier is strong.

Annotations
@Override
processQuantityback to summary
public MicroProps processQuantity(DecimalQuantity quantity)

Implements com.ibm.icu.impl.number.MicroPropsGenerator.processQuantity.

Doc from com.ibm.icu.impl.number.MicroPropsGenerator.processQuantity.

Deprecated

as a consequence of DecimalQuantity being deprecated. See corresponding docs for further information.

Considers the given DecimalQuantity, optionally mutates it, and returns a MicroProps.

Parameters
quantity:DecimalQuantity

The quantity for consideration and optional mutation.

Returns:MicroProps

A MicroProps instance resolved for the quantity.

Annotations
@Override
semanticallyEquivalentback to summary
public boolean semanticallyEquivalent(Modifier other)

Implements com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

Doc from com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

Returns whether this Modifier is *semantically equivalent* to the other Modifier; in many cases, this is the same as equal, but parameters should be ignored.

Annotations
@Override
com.ibm.icu.number back to summary

private Class ScientificNotation.ScientificModifier

extends Object
implements Modifier
Class Inheritance
All Implemented Interfaces
com.ibm.icu.impl.number.Modifier

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final ScientificNotation.ScientificHandler

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
apply(FormattedStringBuilder
The string builder to which to apply this modifier.
output
,
int
The left index of the string within the builder. Equal to 0 when only one number is being formatted.
leftIndex
,
int
The right index of the string within the string builder. Equal to length when only one number is being formatted.
rightIndex
)

Implements com.ibm.icu.impl.number.Modifier.apply.

Apply this Modifier to the string builder.
public boolean
containsField(Format.Field field)

Implements com.ibm.icu.impl.number.Modifier.containsField.

Whether the modifier contains at least one occurrence of the given field.
public int
getCodePointCount()

Implements com.ibm.icu.impl.number.Modifier.getCodePointCount.

Returns the number of code points in the modifier, prefix plus suffix.
public Modifier.Parameters
getParameters()

Implements com.ibm.icu.impl.number.Modifier.getParameters.

Gets a set of "parameters" for this Modifier.
public int
getPrefixLength()

Implements com.ibm.icu.impl.number.Modifier.getPrefixLength.

Gets the length of the prefix.
public boolean
isStrong()

Implements com.ibm.icu.impl.number.Modifier.isStrong.

Whether this modifier is strong.
public boolean
semanticallyEquivalent(Modifier other)

Implements com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

Returns whether this Modifier is *semantically equivalent* to the other Modifier; in many cases, this is the same as equal, but parameters should be ignored.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

exponentback to summary
pack-priv final int exponent
handlerback to summary
pack-priv final ScientificNotation.ScientificHandler handler

Constructor Detail

ScientificModifierback to summary
pack-priv ScientificModifier(int exponent, ScientificNotation.ScientificHandler handler)

Method Detail

applyback to summary
public int apply(FormattedStringBuilder output, int leftIndex, int rightIndex)

Implements com.ibm.icu.impl.number.Modifier.apply.

Doc from com.ibm.icu.impl.number.Modifier.apply.

Apply this Modifier to the string builder.

Parameters
output:FormattedStringBuilder

The string builder to which to apply this modifier.

leftIndex:int

The left index of the string within the builder. Equal to 0 when only one number is being formatted.

rightIndex:int

The right index of the string within the string builder. Equal to length when only one number is being formatted.

Returns:int

The number of characters (UTF-16 code units) that were added to the string builder.

Annotations
@Override
containsFieldback to summary
public boolean containsField(Format.Field field)

Implements com.ibm.icu.impl.number.Modifier.containsField.

Doc from com.ibm.icu.impl.number.Modifier.containsField.

Whether the modifier contains at least one occurrence of the given field.

Annotations
@Override
getCodePointCountback to summary
public int getCodePointCount()

Implements com.ibm.icu.impl.number.Modifier.getCodePointCount.

Doc from com.ibm.icu.impl.number.Modifier.getCodePointCount.

Returns the number of code points in the modifier, prefix plus suffix.

Annotations
@Override
getParametersback to summary
public Modifier.Parameters getParameters()

Implements com.ibm.icu.impl.number.Modifier.getParameters.

Doc from com.ibm.icu.impl.number.Modifier.getParameters.

Gets a set of "parameters" for this Modifier.

Annotations
@Override
getPrefixLengthback to summary
public int getPrefixLength()

Implements com.ibm.icu.impl.number.Modifier.getPrefixLength.

Doc from com.ibm.icu.impl.number.Modifier.getPrefixLength.

Gets the length of the prefix. This information can be used in combination with apply to extract the prefix and suffix strings.

Returns:int

The number of characters (UTF-16 code units) in the prefix.

Annotations
@Override
isStrongback to summary
public boolean isStrong()

Implements com.ibm.icu.impl.number.Modifier.isStrong.

Doc from com.ibm.icu.impl.number.Modifier.isStrong.

Whether this modifier is strong. If a modifier is strong, it should always be applied immediately and not allowed to bubble up. With regard to padding, strong modifiers are considered to be on the inside of the prefix and suffix.

Returns:boolean

Whether the modifier is strong.

Annotations
@Override
semanticallyEquivalentback to summary
public boolean semanticallyEquivalent(Modifier other)

Implements com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

Doc from com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

Returns whether this Modifier is *semantically equivalent* to the other Modifier; in many cases, this is the same as equal, but parameters should be ignored.

Annotations
@Override