Skip to content

Commit c96d29b

Browse files
committed
ir/constnat: minor update of variable names for consistency
The use of part1, part2 is to be consistent with the code for 0xK.
1 parent e8368c7 commit c96d29b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

ir/constant/const_float.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,22 @@ func NewFloatFromString(typ *types.FloatType, s string) (*Float, error) {
7878
return &Float{Typ: typ, X: x, NaN: nan}, nil
7979
case strings.HasPrefix(s, "0xL"):
8080
// From https://llvm.org/docs/LangRef.html#simple-constants
81-
// > The IEEE 128-bit format is represented by 0xL followed by 32 hexadecimal digits.
81+
//
82+
// > The IEEE 128-bit format is represented by 0xL followed by 32
83+
// > hexadecimal digits.
8284
hex := s[len("0xL"):] // first remove the prefix
83-
maxLenOfHex := 32
84-
if len(hex) < maxLenOfHex {
85-
// add zero for the case like: `0xL01` which missing leading 0
86-
hex = strings.Repeat("0", maxLenOfHex-len(hex)) + hex
85+
const maxHexLen = 32
86+
if len(hex) < maxHexLen {
87+
// add zeros for the case like: `0xL01` which is missing leading 0s
88+
hex = strings.Repeat("0", maxHexLen-len(hex)) + hex
8789
}
88-
signAndExponentAnd48Fraction := hex[:maxLenOfHex/2]
89-
restFraction := hex[maxLenOfHex/2:]
90-
a, err := strconv.ParseUint(signAndExponentAnd48Fraction, 16, 64)
90+
part1 := hex[:maxHexLen/2]
91+
part2 := hex[maxHexLen/2:]
92+
a, err := strconv.ParseUint(part1, 16, 64)
9193
if err != nil {
9294
return nil, errors.WithStack(err)
9395
}
94-
b, err := strconv.ParseUint(restFraction, 16, 64)
96+
b, err := strconv.ParseUint(part2, 16, 64)
9597
if err != nil {
9698
return nil, errors.WithStack(err)
9799
}

0 commit comments

Comments
 (0)