[opensource] Re: uint64_t Question

Nick Hurley hurley at todesschaf.org
Mon May 21 08:25:13 EDT 2007


On 21 May 2007, at 01:06, Karen Manukyan wrote:
> Hi Alex,
>
> I would suggest that you don't use atoi, strtol, etc at all. There  
> is better way to do conversions:
>
> http://www.parashift.com/c++-faq-lite/misc-technical- 
> issues.html#faq-39.2
>
> They give an example for double, but you can use any other type  
> instead (see next example on the same page).
>
> -Karen
>
> P.S.
> C++ Rocks! :)

If he's NOT using C++, for whatever reason (plenty of us STRONGLY  
disagree with your "C++ Rocks" statement, for example), then there  
is, in fact, an option:

strtoull(3)

Transforms a string to an unsigned long long (which, on most common  
architectures, will be a uint64_t). Keep in mind, however, that 64- 
bit architectures may, in fact, have a 64-bit int, meaning strtoul  
will work just fine. strtoull(3) exists, to my knowledge, on Linux  
(glibc), OS X libc (likely FreeBSD libc) and OpenBSD libc. I'm not  
certain if strtoull(3) is part of the C standard or not.

And, just to be antagonistic:

C kicks C++'s ass any day of the week!
--
Peace,
   Nick

    "To make a bad day worse, spend it wishing for the impossible." - 
Calvin





More information about the Opensource mailing list