@@ -78,20 +78,22 @@ func NewFloatFromString(typ *types.FloatType, s string) (*Float, error) {
78
78
return & Float {Typ : typ , X : x , NaN : nan }, nil
79
79
case strings .HasPrefix (s , "0xL" ):
80
80
// 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.
82
84
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
87
89
}
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 )
91
93
if err != nil {
92
94
return nil , errors .WithStack (err )
93
95
}
94
- b , err := strconv .ParseUint (restFraction , 16 , 64 )
96
+ b , err := strconv .ParseUint (part2 , 16 , 64 )
95
97
if err != nil {
96
98
return nil , errors .WithStack (err )
97
99
}
0 commit comments