Skip to content

Commit 4ec856a

Browse files
committed
- amend based on review comments
- User rune instead of string for comparison
1 parent cefda0c commit 4ec856a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/strconv/ctoa.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2009 The Go Authors. All rights reserved.
1+
// Copyright 2020 The Go Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

@@ -27,15 +27,15 @@ package strconv
2727
// The special precision -1 uses the smallest number of digits
2828
// necessary such that ParseComplex will return c exactly.
2929
func FormatComplex(c complex128, fmt byte, prec, bitSize int) string {
30-
3130
if bitSize == 64 {
3231
bitSize = 32
3332
} else {
3433
bitSize = 64
3534
}
3635

36+
// Check if imaginary part has a sign. If not, add one.
3737
imag := FormatFloat(imag(c), fmt, prec, bitSize)
38-
if imag[0:1] != "+" && imag[0:1] != "-" {
38+
if imag[0] != '+' && imag[0] != '-' {
3939
imag = "+" + imag
4040
}
4141

0 commit comments

Comments
 (0)