Ah, I wonder if it's down to machine word size.
Code:
$ /lib/x86_64-linux-gnu/libc.so.6
GNU C Library (Ubuntu EGLIBC 2.13-20ubuntu5.2) stable release version 2.13, by Roland McGrath et al.
Here is something out of the glibc vfscanf,c file
Code:
/* Convert the number. */
ADDW (L_('\0'));
if (need_longlong && (flags & LONGDBL))
{
if (flags & NUMBER_SIGNED)
num.q = __strtoll_internal (wp, &tw, base, flags & GROUP);
else
num.uq = __strtoull_internal (wp, &tw, base, flags & GROUP);
}
else
{
if (flags & NUMBER_SIGNED)
num.l = __strtol_internal (wp, &tw, base, flags & GROUP);
else
num.ul = __strtoul_internal (wp, &tw, base, flags & GROUP);
}
It seems to use the widest available strto... function to perform the initial conversion.
What follows next are just a bunch of dumb casts to throw away the msb data, ignoring the actual data type ranges.
Things like this:
Code:
*ARG (short int *) = (short int) num.l;