Skip to content

Commit 4b77a49

Browse files
authored
Merge pull request #36331 from windsonsea/qtyyhf
[zh] Sync1.25 /kubernetes-api/common-definitions/quantity.md
2 parents 9bbc2b2 + 3a0bee7 commit 4b77a49

File tree

1 file changed

+20
-32
lines changed
  • content/zh-cn/docs/reference/kubernetes-api/common-definitions

1 file changed

+20
-32
lines changed

content/zh-cn/docs/reference/kubernetes-api/common-definitions/quantity.md

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ content_type: "api_reference"
77
description: "数量(Quantity)是数字的定点表示。"
88
title: "Quantity"
99
weight: 10
10-
auto_generated: true
1110
---
12-
1311
<!--
1412
api_metadata:
1513
apiVersion: ""
@@ -22,22 +20,8 @@ weight: 10
2220
auto_generated: true
2321
-->
2422

25-
<!--
26-
The file is auto-generated from the Go source code of the component using a generic
27-
[generator](https://github.com/kubernetes-sigs/reference-docs/). To learn how
28-
to generate the reference documentation, please read
29-
[Contributing to the reference documentation](/docs/contribute/generate-ref-docs/).
30-
To update the reference content, please follow the
31-
[Contributing upstream](/docs/contribute/generate-ref-docs/contribute-upstream/)
32-
guide. You can file document formatting bugs against the
33-
[reference-docs](https://github.com/kubernetes-sigs/reference-docs/) project.
34-
-->
35-
36-
37-
3823
`import "k8s.io/apimachinery/pkg/api/resource"`
3924

40-
4125
<!--
4226
Quantity is a fixed-point representation of a number.
4327
It provides convenient marshaling/unmarshaling in JSON and YAML,
@@ -47,7 +31,7 @@ The serialization format is:
4731
-->
4832
数量(Quantity)是数字的定点表示。
4933
除了 String() 和 AsInt64() 的访问接口之外,
50-
它以 JSON 和 YAML形式提供方便的打包和解包方法
34+
它以 JSON 和 YAML 形式提供方便的打包和解包方法
5135

5236
序列化格式如下:
5337

@@ -82,40 +66,44 @@ The serialization format is:
8266
<decimalExponent> ::= "e" <signedNumber> | "E" <signedNumber> </br>
8367
```
8468

85-
8669
<!--
8770
No matter which of the three exponent forms is used, no quantity may represent a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal places. Numbers larger or more precise will be capped or rounded up. (E.g.: 0.1m will rounded up to 1m.) This may be extended in the future if we require larger or smaller quantities.
8871
8972
When a Quantity is parsed from a string, it will remember the type of suffix it had, and will use the same type again when it is serialized.
9073
-->
9174
无论使用三种指数形式中哪一种,没有数量可以表示大于 2<sup>63</sup>-1 的数,也不可能超过 3 个小数位。
92-
更大或更精确的数字将被截断或向上取整(例如:0.1m 将向上取整为 1m。)
75+
更大或更精确的数字将被截断或向上取整(例如:0.1m 将向上取整为 1m)。
9376
如果将来我们需要更大或更小的数量,可能会扩展。
9477

9578
当从字符串解析数量时,它将记住它具有的后缀类型,并且在序列化时将再次使用相同类型。
9679

9780
<!--
98-
Before serializing, Quantity will be put in "canonical form".
99-
This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:
100-
a. No precision is lost
101-
b. No fractional digits will be emitted
102-
c. The exponent (or suffix) is as large as possible.
81+
Before serializing, Quantity will be put in "canonical form". This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:
82+
83+
- No precision is lost
84+
- No fractional digits will be emitted
85+
- The exponent (or suffix) is as large as possible.
86+
10387
The sign will be omitted unless the number is negative.
10488
-->
10589
在序列化之前,数量将以“规范形式”放置。这意味着指数或者后缀将被向上或向下调整(尾数相应增加或减少),并确保:
106-
1. 没有精度丢失
107-
2. 不会输出小数数字
108-
3. 指数(或后缀)尽可能大。
90+
91+
- 没有精度丢失
92+
- 不会输出小数数字
93+
- 指数(或后缀)尽可能大。
94+
10995
除非数量是负数,否则将省略正负号。
11096

11197
<!--
11298
Examples:
113-
1.5 will be serialized as "1500m"
114-
1.5Gi will be serialized as "1536Mi"
99+
100+
- 1.5 will be serialized as "1500m"
101+
- 1.5Gi will be serialized as "1536Mi"
115102
-->
116103
例如:
117-
- 1.5 将会被序列化成 “1500m”
118-
- 1.5Gi 将会被序列化成 “1536Mi”
104+
105+
- 1.5 将会被序列化成 “1500m”
106+
- 1.5Gi 将会被序列化成 “1536Mi”
119107

120108
<!--
121109
Note that the quantity will NEVER be internally represented by a floating point number.
@@ -128,7 +116,7 @@ This format is intended to make it difficult to use these numbers without writin
128116
-->
129117
请注意,数量永远**不会**在内部以浮点数表示。这是本设计的重中之重。
130118

131-
只要它们格式正确,非规范值仍将解析,但将以其规范形式重新输出(所以应该总是使用规范形式,否则不要执行 diff 比较。)
119+
只要它们格式正确,非规范值仍将解析,但将以其规范形式重新输出(所以应该总是使用规范形式,否则不要执行 diff 比较)。
132120

133121
这种格式旨在使得很难在不撰写某种特殊处理代码的情况下使用这些数字,进而希望实现者也使用定点实现。
134122

0 commit comments

Comments
 (0)