Decimal Seperator in Mac OS X

Preference Pane
The decimal separator is set in Mac OS X in the System preferences, under Language & Region, Advanced settings. In this dialog, you can set:


 * Format language
 * Number grouping (thousands) separator
 * Number decimal separator
 * Currency grouping (thousands) separator
 * Currency decimal separator

From the Command Line
These settings are stored in the preference file ~/Library/Preferences/.GlobalPreferences.plist, which you can access with this command:

defaults read .GlobalPreferences AppleLocale defaults read .GlobalPreferences AppleICUNumberSymbols

The AppleLocale contains information about the Region, the Format Lanugage, and the Currency symbol. The AppleICUNumberSymbols contains information about the number separator.

The Region determines the default currency symbol. The Format Lanugage determines the default number separators. The currency symbol and number separators are only included in the .GlobalPreferences if they deviate from the default.

Reading the Settings
In the following example, the Locale was set to Netherlands Region, English formatting, US dollar currency:

% defaults read .GlobalPreferences AppleLocale en_NL@currency=USD

And in the following example, the grouping (thousands) separator was set to a space, and the decimal separator is set to a dot: ~% defaults read .GlobalPreferences AppleICUNumberSymbols {    0 = ".";     1 = "\\U00a0"; 10 = ".";    17 = "\\U00a0"; }

Writing the Settings
In the following example, the Locale will be set to Netherlands Region, English formatting, US dollar currency:

% defaults write .GlobalPreferences AppleLocale en_NL@currency=USD

And in the following example, the grouping (thousands) separator will be set to a dot, and the decimal separator is set to a comma:

~% defaults write .GlobalPreferences AppleICUNumberSymbols -dict 0 '.' 1 ',' 10 '.' 17 ','

Application Behaviour
All applications need to be quit and restarted before changes take effect. It is not necessary to log out or reboot the computer.

Calculator
Apple's Calculator, simply uses the standard values as described above.

Script Editor (AppleScript)
Open the Script Editor, and run this small AppleScript: display dialog item 2 of ((1/2) as string)

In recent versions of OS X, it simple follows the conventions set in the preference pane. Up to Mac OS 10.5, all I ever got was a dot (.). However, this may be a quirk in my measurements at the time.

Microsoft Excel
Both Microsoft Excel, as well as Apple's Numbers (another database program), seem to use the decimal separator as set the preference pane.

However, in case the decimal separator is a comma, a formula like MAX(1,2) become ambiguous: does it mean the Maximum of 1 and 2, or the maximum of 1.20? Both Excel and Number change the formula argument separator to a semicolon, but their behaviour is different. In particular, Excel behaves unexpectedly.

It seems that:
 * Excel both takes the decimal separator, as well as the default decimal separator for a given language into account, and if one of them is a comma, it changes the formula argument separator to a semicolon.
 * Excel also changes the delimiter (field separator) of CSV files, despite that the name CSV stands for Comma-separated values.

Note: a workaround to enforce MS Excel to use a comma as delimiter in CSV is to add the following directive to the first line of a CVS file:

sep=,

Previous Systems
In previous systems (at least up to 10.4), these settings have been stored in other files as well:

defaults read .GlobalPreferences defaults read /Library/Preferences/.GlobalPreferences defaults read com.apple.systempreferences defaults read com.apple.HIToolbox

Furthermore, the default values (for each Region/Format language) seem to be stored in these files: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/*.lproj/Localized.rsrc, with the star replaced by a Locale, e.g. Dutch.lproj, English.lproj, or ca.lproj.

Mac OS 10.3
In Mac OS 10.3, the settings were stored in three places:

defaults write .GlobalPreferences AppleICUNumberSymbols -dict 0 '.' 1 ',' 8 '€' 10 '.' 17 ',' defaults write .GlobalPreferences AppleICUNumberFormatStrings -dict-add 2 '#,##0.00¤;-#,##0.00¤' defaults write com.apple.HIToolbox AppleDecimalSeparator -dict smRoman '.' defaults write com.apple.HIToolbox AppleThousandSeparator -dict smRoman ','

In this example, the number format is set to "1,234.00€".

Unconfirmed Locations
defaults write .GlobalPreferences NSDecimalSeparator       '.' defaults write .GlobalPreferences NSThousandSeparator      ',' defaults write .GlobalPreferences NSGroupingSeparator. ',' defaults write com.apple.systempreferences AppleIntlCustomFormat -dict-add AppleDecimalSeparator '.' defaults write com.apple.systempreferences AppleIntlCustomFormat -dict-add AppleThousandSeparator ',' defaults write .GlobalPreferences AppleDecimalSeparator    '.' defaults write .GlobalPreferences NSLocaleDecimalSeparator '.' defaults write com.apple.HIToolbox NSDecimalSeparator       '.' defaults write com.apple.HIToolbox NSLocaleDecimalSeparator '.' defaults write com.apple.systempreferences AppleDecimalSeparator    '.' defaults write com.apple.systempreferences NSDecimalSeparator       '.' defaults write com.apple.systempreferences NSLocaleDecimalSeparator '.'
 * 1) Format as suggestion on rixstep.com
 * 1) Format as suggestion on AppleScript mailing list
 * 1) Really speculative places (unlikely to be correct)

Mac OS 10.4 and 10.5 Issue
In Mac OS 10.4 (Tiger) and Mac OS 10.5 (Leopard), there is no easy way to set the decimal separator (the decimal point) to a custom format (10 000.00) rather than European (10.000,00) or US format (10,000.00).

This worked fine in Mac OS 10.3, and it took until Mac OS 10.6 until this was fixed.

In Mac OS 10.3, this format was customizable in the "Internationalization" preference pane, on the "Formats" tab. Even in 10.4 and 10.5, you can select a preset from a long list, and further customize the date format and the time format. However, if you want a specific language. Say, Dutch or German there is no way you can have anything but "10.000,00" as the number format.

There were a few solutions:


 * Tweak an existing locale:Use the defaults write commands explained above.
 * Use the 10.3 Preference pane:If you have a PowerPC, you can use the 10.3 preference pane, as described on the Mac OS X hints website: 10.4: Restore custom international number formats.
 * Find a copy of the Localization.prefPane on a Panther system.
 * Copy this file (bundle) to ~/Library/PreferencePanes/ on your 10.4 system. From then on, if you open the system preferences, you will simply get the (much better) 10.3 preference pane, which simply allows you to change the number format and the decimal point.


 * Create a custom locale:Theoretically, it is possible to define a custom Region or language, and set your own defaults in the /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/MyRegion.lproj/Localized.rsrc. I expect that the actual info is stored in a itl0 resources in the resource fork of these files. That said, I really discourage you from changing anything in the /System/Library</tt> directory.