Type Method

decimalNumberWithString:locale:

Creates a decimal number whose value is equivalent to that in a given numeric string, interpreted using a given locale.

Declaration

+ (NSDecimalNumber *)decimalNumberWithString:(NSString *)numberValue locale:(id)locale;

Parameters

numericString

A numeric string.

Besides digits, numericString can include an initial + or ; a single E or e, to indicate the exponent of a number in scientific notation; and a single decimal separator character to divide the fractional from the integral part of the number.

locale

A dictionary that defines the locale (specifically the NSLocaleDecimalSeparator) to use to interpret the number in numericString.

Discussion

The locale parameter determines whether the NSLocaleDecimalSeparator is a period (like in the United States) or a comma (like in France).

The following strings show examples of acceptable values for numericString:

  • 2500.6 (or 2500,6, depending on locale)

  • –2500.6 (or –2500,6)

  • –2.5006e3 (or –2,5006e3)

  • –2.5006E3 (or –2,5006E3)

The following strings are unacceptable:

  • 2,500.6

  • 2500 3/5

  • 2.5006x10e3

  • two thousand five hundred and six tenths

See Also

Creating a Decimal Number

+ decimalNumberWithDecimal:

Creates and returns a decimal number equivalent to a given decimal structure.

+ decimalNumberWithMantissa:exponent:isNegative:

Creates and returns a decimal number equivalent to the number specified by the arguments.

+ decimalNumberWithString:

Creates a decimal number whose value is equivalent to that in a given numeric string.

one

A decimal number equivalent to the number 1.0.

zero

A decimal number equivalent to the number 0.0.

notANumber

A decimal number that specifies no number.