Operating System - Linux
1762897 Members
1583 Online
108909 Solutions
New Discussion юеВ

Re: Absolute values for a long long integer

 
hemcreddy
New Member

Absolute values for a long long integer

Hello,

Could someone tell me how to get absolute value for a 64-bit integer on HP-UX 11.23 IA? I could see "long int labs(long int i)" @ http://docs.hp.com/en/B3921-60631/abs.3C.html for a 32-bit integer.

Sizeof(int) & sizeof(long int) print 4 and sizeof(long long int) & sizeof(int64_t) print 8 on my machine.

# aCC -V
aCC: HP aC++/ANSI C B3910B A.06.00 [Aug 25 2004]


Thanks,
Hem

5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: Absolute values for a long long integer

You do it the old fashion way, with inline code:
long long ll1 = -1LL;
long long ll2 = ll1 < 0LL ? -ll1 : ll1;
If you are on 11.31, llabs(3) exists.
OFC_EDM
Respected Contributor

Re: Absolute values for a long long integer

Little out of my area

Maybe this has the info you need
http://hpcjl.ustc.edu.cn/doc/HP-UX32bit-64bit%20zhuyi.pdf
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: Absolute values for a long long integer

hemcreddy
New Member

Re: Absolute values for a long long integer

Thank you very much for your suggestions.

Regards,
Hem
Dennis Handly
Acclaimed Contributor

Re: Absolute values for a long long integer

If you are happy with our suggestions please read the following about assigning points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33