Operating System - HP-UX
1834804 Members
2332 Online
110070 Solutions
New Discussion

64-bit integer operations?

 
SOLVED
Go to solution
Clay Porter
Occasional Contributor

64-bit integer operations?

64 bit integers are represented by "long long" or int64.
Are there any functions available to operate on these 64-bit integers?

I am looking for something like lltostr(), strtoll().

TIA.
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: 64-bit integer operations?

Hi:

It rather amazed me that couldn't find those functions when I needed them the first time.

Fortunately, the strtoll is easy to do be at least in decimal, octal, or hex. I simply do something like this:

sprintf(my_str,"%lld",my_long_long);

Note the "%lld" format specifier; obiously "%llo" and "%llx" could be used for octal and hexadecimal respectively.

The atoll is a bit trickier; I have not needed a strtoll for non-decimal conversion so I have not attempted a true strtoll() but the attached atoll works nicely.

Regards, Clay
If it ain't broke, I can fix that.