Decimal
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
JSON 表示法 |
{
"value": string
} |
欄位 |
value |
string
十進位值,以字串表示。 字串表示由選用符號 + (U+002B ) 或 - (U+002D ) 組成,後面接著一串零或更多小數位數 (即「整數」),後面加上分數,後面可加上指數。空白字串應解譯為 0 。 分數由小數點組成,後面接著零或更多小數位數。字串中必須含有至少一個整數或分數值。由符號、整數和分數構成的數值稱為重要符號。 指數由 e (U+0065 ) 或 E (U+0045 ) 字元組成,後面接著一或多個小數。 服務「應該」將小數值標準化:
- 移除明確提供的
+ 符號 (+2.5 -> 2.5 )。
- 將零長度整數值替換為
0 (.5 -> 0.5 )。
- 將指數字元強制轉換為大寫,含明確的符號 (
2.5e8 -> 2.5E+8 )。
- 移除明確提供的零指數 (
2.5E0 -> 2.5 )。
服務可能會根據自己的需求和內部小數實作執行額外的正規化處理,例如同時移動小數點和指數值 (例如:2.5E-1 <-> 0.25 )。此外,服務「可能」會保留分數的結尾零,表示精確度更高,但並非必要。 請注意,系統僅支援 . 字元來分隔整數和分數;無論地區設定為何,系統都不應支援 , 。此外,系統不應支援數千個分隔符。如果服務可支援,則必須將值正規化。 ENBF 文法如下:
DecimalString =
'' | [Sign] Significand [Exponent];
Sign = '+' | '-';
Significand =
Digits ['.'] [Digits] | [Digits] '.' Digits;
Exponent = ('e' | 'E') [Sign] Digits;
Digits = { '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' };
服務應明確記錄支援的值範圍、支援的精確度上限 (總數) 和比例 (如果有的話),以及小數值 (小數)。 即使服務具有更高的精確度或縮放值,服務仍可以接受做為輸入值傳遞的值,並應將這個值四捨五入,以符合支援的比例。此外,如果精確度的話,服務「可能」會出現 400 Bad Request 錯誤 (gRPC 中的 INVALID_ARGUMENT )。 如果服務收到超出支援範圍的值,則服務應傳回 400 Bad Request (gRPC 中的 INVALID_ARGUMENT )。
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2022-12-20 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2022-12-20 (世界標準時間)。"],[[["Decimal values are represented as strings in JSON, using a format similar to that of standard programming languages."],["The decimal string representation allows for an optional sign, integer part, fractional part, and exponent."],["Services are encouraged to normalize decimal values before storage for consistency, for example by removing leading plus signs or zero-length integer values."],["While services should document their supported range, precision, and scale for decimal values, they may handle out-of-bounds values through rounding or error responses."],["Thousand separators and the comma as a decimal separator are not supported in this representation and should be normalized if encountered by a service."]]],[]]