Article View: gnu.gcc.help
Article #52699Help I need to print a long long
From: Daniel C. O'Connor
Date: Fri, 22 May 1992 21:21
Date: Fri, 22 May 1992 21:21
63 lines
1886 bytes
1886 bytes
Sorry if this is a FAQ but...
I am working with long long variables and I have the following two problems:
1) what is the format of a printf statement that will print a long long
variable in hexadecimal format. I've tried everything I can think of
or find in any documentation and nothing seems to work. The best I
can seem to do is to print the upper half of the long long.
2) How can I assign a long long to a constant. I have tried the following
two approaches
A) main
{
long long Foo;
Foo = 0x0123456789ABCDEF;
};
when I compile using the gcc -Wall -O -ansi Foo.c, it returns a
constant out of range error.
b) main
{
long long Foo;
Foo = 0x01234567;
Foo = Foo<<32;
Foo = Foo | 0x89ABCDEF;
};
This seems to work fine until I want to put this shift-or stuff into a
function like this:
long long AssignALongLong(temp1, temp2)
long temp1, temp2;
{
long long temp3;
temp3 = temp1;
temp3 = temp3<<32;
temp3 = temp3 | temp2;
};
When I call AssignALongLong like this:
...
Foo = AssignALongLong(0x01234567,0x89ABCDEF);
...
The problem is that it seems Foo equals 0xFFFFFFFF89ABCDEF after this
function call.
Any help will be greatly appreciated.
Please send responses to doconnor@apple.com.
Thanks,
Dan O'Connor
Technical Details
Message-ID:
<25578@goofy.Apple.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!decwrl!claris!apple!apple.com!doconnorShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,be56f165a05031d4,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1992-05-22 22:35:26 PST Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!claris!apple!apple.com!doconnor From: doconnor@apple.com (Daniel C. O'Connor) Newsgroups: gnu.gcc.help Subject: Help I need to print a long long Message-ID: <25578@goofy.Apple.COM> Date: 22 May 92 21:21:57 GMT Sender: usenet@Apple.COM Distribution: gnu Organization: Apple Computer, Inc Lines: 63