Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
e109a2bb
Commit
e109a2bb
authored
Jul 21, 2011
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
big: minor comment adjustments
R=mtj, r CC=golang-dev
https://golang.org/cl/4814044
parent
12c73615
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
src/pkg/big/int.go
src/pkg/big/int.go
+12
-9
No files found.
src/pkg/big/int.go
View file @
e109a2bb
...
@@ -329,9 +329,9 @@ func writeMultiple(s fmt.State, text string, count int) {
...
@@ -329,9 +329,9 @@ func writeMultiple(s fmt.State, text string, count int) {
// Format is a support routine for fmt.Formatter. It accepts
// Format is a support routine for fmt.Formatter. It accepts
// the formats 'b' (binary), 'o' (octal), 'd' (decimal), 'x'
// the formats 'b' (binary), 'o' (octal), 'd' (decimal), 'x'
// (lowercase hexadecimal), and 'X' (uppercase hexadecimal).
// (lowercase hexadecimal), and 'X' (uppercase hexadecimal).
// Also supported are the full suite of
"Printf" style
format
// Also supported are the full suite of
package fmt's
format
//
codes for integral types, including PLUS, MINUS, and SPACE
//
verbs for integral types, including '+', '-', and ' '
// for sign control,
HASH for leading ZERO
in octal and for
// for sign control,
'#' for leading zero
in octal and for
// hexadecimal, a leading "0x" or "0X" for "%#x" and "%#X"
// hexadecimal, a leading "0x" or "0X" for "%#x" and "%#X"
// respectively, specification of minimum digits precision,
// respectively, specification of minimum digits precision,
// output field width, space or zero padding, and left or
// output field width, space or zero padding, and left or
...
@@ -378,9 +378,9 @@ func (x *Int) Format(s fmt.State, ch int) {
...
@@ -378,9 +378,9 @@ func (x *Int) Format(s fmt.State, ch int) {
// determine digits with base set by len(cs) and digit characters from cs
// determine digits with base set by len(cs) and digit characters from cs
digits
:=
x
.
abs
.
string
(
cs
)
digits
:=
x
.
abs
.
string
(
cs
)
// number of characters for the
Sprintf family's
three classes of number padding
// number of characters for the three classes of number padding
var
left
int
// space characters to left of digits for right justification ("%8d")
var
left
int
// space characters to left of digits for right justification ("%8d")
var
zeroes
int
// zero characters (ac
ut
ally cs[0]) as left-most digits ("%.8d")
var
zeroes
int
// zero characters (ac
tu
ally cs[0]) as left-most digits ("%.8d")
var
right
int
// space characters to right of digits for left justification ("%-8d")
var
right
int
// space characters to right of digits for left justification ("%-8d")
// determine number padding from precision: the least number of digits to output
// determine number padding from precision: the least number of digits to output
...
@@ -398,16 +398,19 @@ func (x *Int) Format(s fmt.State, ch int) {
...
@@ -398,16 +398,19 @@ func (x *Int) Format(s fmt.State, ch int) {
length
:=
len
(
sign
)
+
len
(
prefix
)
+
zeroes
+
len
(
digits
)
length
:=
len
(
sign
)
+
len
(
prefix
)
+
zeroes
+
len
(
digits
)
if
width
,
widthSet
:=
s
.
Width
();
widthSet
&&
length
<
width
{
// pad as specified
if
width
,
widthSet
:=
s
.
Width
();
widthSet
&&
length
<
width
{
// pad as specified
switch
d
:=
width
-
length
;
{
switch
d
:=
width
-
length
;
{
case
s
.
Flag
(
'-'
)
:
// pad on the right with spaces. supersedes '0' when both specified
case
s
.
Flag
(
'-'
)
:
// pad on the right with spaces; supersedes '0' when both specified
right
=
d
right
=
d
case
s
.
Flag
(
'0'
)
&&
!
precisionSet
:
// pad with zeroes unless precision also specified
case
s
.
Flag
(
'0'
)
&&
!
precisionSet
:
// pad with zeroes unless precision also specified
zeroes
=
d
zeroes
=
d
default
:
// pad on the left with spaces
default
:
// pad on the left with spaces
left
=
d
left
=
d
}
}
}
}
// print
Int
as [left pad][sign][prefix][zero pad][digits][right pad]
// print
number
as [left pad][sign][prefix][zero pad][digits][right pad]
writeMultiple
(
s
,
" "
,
left
)
writeMultiple
(
s
,
" "
,
left
)
writeMultiple
(
s
,
sign
,
1
)
writeMultiple
(
s
,
sign
,
1
)
writeMultiple
(
s
,
prefix
,
1
)
writeMultiple
(
s
,
prefix
,
1
)
...
...
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