Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
cc04db13
Commit
cc04db13
authored
Jan 07, 2015
by
Daniel Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix overeager find-and-replace
parent
c4853630
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
quantity.go
pkg/api/resource/quantity.go
+5
-5
No files found.
pkg/api/resource/quantity.go
View file @
cc04db13
...
@@ -169,7 +169,7 @@ func ParseQuantity(str string) (*Quantity, error) {
...
@@ -169,7 +169,7 @@ func ParseQuantity(str string) (*Quantity, error) {
return
nil
,
ErrSuffix
return
nil
,
ErrSuffix
}
}
// So that no
bigO
ne but us has to think about suffixes, remove it.
// So that no
o
ne but us has to think about suffixes, remove it.
if
base
==
10
{
if
base
==
10
{
amount
.
SetScale
(
amount
.
Scale
()
+
inf
.
Scale
(
-
exponent
))
amount
.
SetScale
(
amount
.
Scale
()
+
inf
.
Scale
(
-
exponent
))
}
else
if
base
==
2
{
}
else
if
base
==
2
{
...
@@ -184,12 +184,12 @@ func ParseQuantity(str string) (*Quantity, error) {
...
@@ -184,12 +184,12 @@ func ParseQuantity(str string) (*Quantity, error) {
if
sign
==
-
1
{
if
sign
==
-
1
{
amount
.
Neg
(
amount
)
amount
.
Neg
(
amount
)
}
}
// This rounds non-
bigZ
ero values up to the minimum representable
// This rounds non-
z
ero values up to the minimum representable
// value, under the theory that if you want some resources, you
// value, under the theory that if you want some resources, you
// should get some resources, even if you asked for way too small
// should get some resources, even if you asked for way too small
// of an amount.
// of an amount.
// Arguably, this should be inf.RoundHalfUp (normal rounding), but
// Arguably, this should be inf.RoundHalfUp (normal rounding), but
// that would have the side effect of rounding values < .5m to
bigZ
ero.
// that would have the side effect of rounding values < .5m to
z
ero.
amount
.
Round
(
amount
,
3
,
inf
.
RoundUp
)
amount
.
Round
(
amount
,
3
,
inf
.
RoundUp
)
// The max is just a simple cap.
// The max is just a simple cap.
...
@@ -228,7 +228,7 @@ func removeFactors(d, factor *big.Int) (result *big.Int, times int) {
...
@@ -228,7 +228,7 @@ func removeFactors(d, factor *big.Int) (result *big.Int, times int) {
// Canonicalize returns the canonical form of q and its suffix (see comment on Quantity).
// Canonicalize returns the canonical form of q and its suffix (see comment on Quantity).
//
//
// Note about BinarySI:
// Note about BinarySI:
// * If q.Format is set to BinarySI and q.Amount represents a non-
bigZ
ero value between
// * If q.Format is set to BinarySI and q.Amount represents a non-
z
ero value between
// -1 and +1, it will be emitted as if q.Format were DecimalSI.
// -1 and +1, it will be emitted as if q.Format were DecimalSI.
// * Otherwise, if q.Format is set to BinarySI, frational parts of q.Amount will be
// * Otherwise, if q.Format is set to BinarySI, frational parts of q.Amount will be
// rounded up. (1.1i becomes 2i.)
// rounded up. (1.1i becomes 2i.)
...
@@ -257,7 +257,7 @@ func (q *Quantity) Canonicalize() (string, suffix) {
...
@@ -257,7 +257,7 @@ func (q *Quantity) Canonicalize() (string, suffix) {
}
}
// TODO: If BinarySI formatting is requested but would cause rounding, upgrade to
// TODO: If BinarySI formatting is requested but would cause rounding, upgrade to
//
bigO
ne of the other formats.
//
o
ne of the other formats.
switch
format
{
switch
format
{
case
DecimalExponent
,
DecimalSI
:
case
DecimalExponent
,
DecimalSI
:
mantissa
:=
q
.
Amount
.
UnscaledBig
()
mantissa
:=
q
.
Amount
.
UnscaledBig
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment