[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#166403: libc6: scanf hex float without exponent



Package: libc6
Version: 2.3.1-3

I noticed scanf and friends seem to demand an exponent on hex format
float inputs, whereas my reading of the doco suggests it should be
optional.

The program

	int
	main ()
	{
	  double d = -999;
	  int  ret;
	  ret =  sscanf ("0x100", "%lg", &d);
	  printf ("%d %g\n", ret, d);
	}

prints "0 -999" where I had hoped for "1 256" (which is what results
if the input is changed to "0x100p0").

In the manual, scanf says it follows strtod, which in turn says the
exponent is only optional.  And strtod does indeed seem to allow just
"0x100".

I'm aware c99 has a note about certain inputs which are acceptable to
strtod etc are not accepted by scanf, on account of the latter being
unable to backtrack, but I wouldn't have thought that applies in this
case.



Reply to: