On Wed, 2007-10-24 at 21:49 +0100, William S Fulton wrote: > Any portable solutions for extracting the unsigned long long number?
The best effort I can provide is what's in Glib. They do what Sisyphus suggests: represent big numbers as strings if necessary. #ifdef _MSC_VER # include <stdlib.h> #endif #ifdef WIN32 # ifdef _MSC_VER # define PORTABLE_STRTOULL(str, end, base) _strtoui64 (str, end, base) # else # define PORTABLE_STRTOULL(str, end, base) strtoul (str, end, base) # endif #else # define PORTABLE_STRTOULL(str, end, base) strtoull (str, end, base) #endif guint64 SvGUInt64 (SV *sv) { #ifdef USE_64_BIT_ALL return SvUV (sv); #else return PORTABLE_STRTOULL (SvPV_nolen (sv), NULL, 10); #endif } SV * newSVGUInt64 (guint64 value) { #ifdef USE_64_BIT_ALL return newSVuv (value); #else char string[25]; STRLEN length; SV *sv; /* newSVpvf doesn't seem to work correctly. */ length = sprintf(string, "%llu", value); sv = newSVpv (string, length); return sv; #endif } This seems to work OK on most Unices, but doesn't seem to cut it on Win32. It compiles, but according to testers, the 64 bit number tests fail. If anyone can offer any improvements, they'd be more than welcome. -- Bye, -Torsten