- 追加された行はこのように表示されます。
- 削除された行は
このように表示されます。
[[← 3 節に戻る|Palm OS Programmer's Companion Volume I/12-3]] [[↑12 章トップへ|Palm OS Programmer's Companion Volume I/12]] [[5 節に進む →|Palm OS Programmer's Companion Volume I/12-5]]
----
!!!12-4 数値表現
アプリケーションで大きな数値や浮動小数点数を表示する場合、以下の手順に従ってハンドヘルドの地域に適した桁区切りと小数点記号を使用する必要があります(リスト 12.1 を参照して下さい)。
+合衆国の慣習を使用して数値文字列を保存します。すなわち、“,”を桁区切り文字、“.”を小数点として使用します。
+PrefGetPreference および LocGetNumberSeparators を使用して、数値文字列がどのように表示されるべきかを取得します。
+StrLocalizeNumber を使用してローカライズを行ないます。
+ユーザーが入力した数値を同じように操作する必要がある場合、StrDelocalizeNumber を使用して合衆国の慣習に変換します。
!リスト 12.1 数値文字列の扱い
// store numbers using US conventions.
Char *jackpot = "20,000,000.00";
Char thou; // thousand separator
Char dp; // decimal separator
// Retrieve user’s preferred number format.
LocGetNumberSeparators( (NumberFormatType)PrefGetPreference(prefNumberFormat), &thou, &dp );
// Localize jackpot number. Converts "," to thou
// and "." to dp.
StrLocalizeNumber(jackpot, thou, dp);
// Display string.
// Assume inputString is a number user entered,
// convert it to US conventions this way. Converts
// thou to "," and dp to "."
StrDelocalizeNumber(inputNumber, thou, dp);
----
[[← 3 節に戻る|Palm OS Programmer's Companion Volume I/12-3]] [[↑12 章トップへ|Palm OS Programmer's Companion Volume I/12]] [[5 節に進む →|Palm OS Programmer's Companion Volume I/12-5]]