Wednesday, May 15, 2024
HomeGolangPotential bug in strconv.ParseFloat - Getting Assist

Potential bug in strconv.ParseFloat – Getting Assist


Whereas checking an microservice of our, i seen that it fails to simply accept strings like these:
“0x15e-2”.

The service internally makes use of strconv.ParseFloat, and the string above is taken straight from the go ref (The Go Programming Language Specification – The Go Programming Language).

The error is:

 strconv.ParseFloat: parsing "0x15e-2": invalid syntax

A minimal instance to breed the error:

Is that this an error within the go spec or an error inside ParseFloat ?

Regards
Ferdinand Linnenberg

Hello @Scarjit ,

I feel the error happens as a result of the exponent for hex numbers should begin with a “p”. The letter “e” is ambiguous as it is usually a sound hexadecimal digit.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments