Debian Codegraph @

google/type/decimal.proto

raw
1 // Copyright 2026 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 syntax = "proto3";
16
17 package google.type;
18
19 option go_package = "google.golang.org/genproto/googleapis/type/decimal;decimal";
20 option java_multiple_files = true;
21 option java_outer_classname = "DecimalProto";
22 option java_package = "com.google.type";
23 option objc_class_prefix = "GTP";
24
25 // A representation of a decimal value, such as 2.5. Clients may convert values
26 // into language-native decimal formats, such as Java's
27 // [BigDecimal](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html)
28 // or Python's
29 // [decimal.Decimal](https://docs.python.org/3/library/decimal.html).
30 message Decimal {
31 // The decimal value, as a string.
32 //
33 // The string representation consists of an optional sign, `+` (`U+002B`)
34 // or `-` (`U+002D`), followed by a sequence of zero or more decimal digits
35 // ("the integer"), optionally followed by a fraction, optionally followed
36 // by an exponent. An empty string **should** be interpreted as `0`.
37 //
38 // The fraction consists of a decimal point followed by zero or more decimal
39 // digits. The string must contain at least one digit in either the integer
40 // or the fraction. The number formed by the sign, the integer and the
41 // fraction is referred to as the significand.
42 //
43 // The exponent consists of the character `e` (`U+0065`) or `E` (`U+0045`)
44 // followed by one or more decimal digits.
45 //
46 // Services **should** normalize decimal values before storing them by:
47 //
48 // - Removing an explicitly-provided `+` sign (`+2.5` -> `2.5`).
49 // - Replacing a zero-length integer value with `0` (`.5` -> `0.5`).
50 // - Coercing the exponent character to upper-case, with explicit sign
51 // (`2.5e8` -> `2.5E+8`).
52 // - Removing an explicitly-provided zero exponent (`2.5E0` -> `2.5`).
53 //
54 // Services **may** perform additional normalization based on its own needs
55 // and the internal decimal implementation selected, such as shifting the
56 // decimal point and exponent value together (example: `2.5E-1` <-> `0.25`).
57 // Additionally, services **may** preserve trailing zeroes in the fraction
58 // to indicate increased precision, but are not required to do so.
59 //
60 // Note that only the `.` character is supported to divide the integer
61 // and the fraction; `,` **should not** be supported regardless of locale.
62 // Additionally, thousand separators **should not** be supported. If a
63 // service does support them, values **must** be normalized.
64 //
65 // The ENBF grammar is:
66 //
67 // DecimalString =
68 // '' | [Sign] Significand [Exponent];
69 //
70 // Sign = '+' | '-';
71 //
72 // Significand =
73 // Digits ['.'] [Digits] | [Digits] '.' Digits;
74 //
75 // Exponent = ('e' | 'E') [Sign] Digits;
76 //
77 // Digits = { '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' };
78 //
79 // Services **should** clearly document the range of supported values, the
80 // maximum supported precision (total number of digits), and, if applicable,
81 // the scale (number of digits after the decimal point), as well as how it
82 // behaves when receiving out-of-bounds values.
83 //
84 // Services **may** choose to accept values passed as input even when the
85 // value has a higher precision or scale than the service supports, and
86 // **should** round the value to fit the supported scale. Alternatively, the
87 // service **may** error with `400 Bad Request` (`INVALID_ARGUMENT` in gRPC)
88 // if precision would be lost.
89 //
90 // Services **should** error with `400 Bad Request` (`INVALID_ARGUMENT` in
91 // gRPC) if the service receives a value outside of the supported range.
92 string value = 1;
93 }