Question about pack function in 64bit 2 core CPU

S

sonet

The pack('N',$A) is 4 bytes in 32bit CPU.
But, the result is still 4 bytes in 64bit 2 core CPU?
Have any difference between 64bits and 32bits CPU in ActivePerl?
 
S

Sisyphus

sonet said:
The pack('N',$A) is 4 bytes in 32bit CPU.
But, the result is still 4 bytes in 64bit 2 core CPU?
Have any difference between 64bits and 32bits CPU in ActivePerl?

'N' is for unsigned longs - and an unsigned long is 4 bytes on both 32-bit
and 64-bit builds.

Perhaps you want pack('Q', $A) ?

Cheers,
Rob
 
S

sonet

Thanks!


Q An unsigned quad value.
(Quads are available only if your system supports 64-bit
integer values _and_ if Perl has been compiled to support those.
Causes a fatal error otherwise.)

The parameter Q is just for 64bit cpu.
I have so many code is developer on 32bits cpu.
I just want to know what do i need rewrite the code?
 
S

sonet

Thanks!


Q An unsigned quad value.
(Quads are available only if your system supports 64-bit
integer values _and_ if Perl has been compiled to support those.
Causes a fatal error otherwise.)

The parameter Q is just for 64bit cpu.
I have so many code is developer on 32bits cpu.
I just want to know have any code i need to rewrite!
 
P

Peter J. Holzer

'N' is for unsigned longs - and an unsigned long is 4 bytes on both 32-bit
and 64-bit builds.

This is true only for pack, which defines 'L', 'N', and 'V' to be always
exactly 32 bit, regardless of the size of an 'unsigned long' defined by
the native C compiler (you get the latter with 'L!').

In C an 'unsigned long' is at least 32 bits. On 64-bit systems it is
often (but not always) 64 bits long.

It is better to avoid using the terms 'long' and 'short' for 'N', 'V',
'L', 'l', 'n', 'v', 'S' and 's', to avoid confusion with the C types of
the same name. Call them 32-bit resp. 16 bit values in network, vax, or
native byte order instead.

hp
 
Q

QoS

sonet said:
Thanks!


Q An unsigned quad value.
(Quads are available only if your system supports 64-bit
integer values _and_ if Perl has been compiled to support those.
Causes a fatal error otherwise.)

The parameter Q is just for 64bit cpu.
I have so many code is developer on 32bits cpu.
I just want to know have any code i need to rewrite!

Anything that uses CRC may need to be inspected again.
 
S

Sisyphus

Peter J. Holzer said:
..
.. ..
..
In C an 'unsigned long' is at least 32 bits. On 64-bit systems it is
often (but not always) 64 bits long.

Yes - I was referring specifically to ActivePerl, where 'perl -V:longsize'
is '4' on both the 32-bit and 64-bit versions.

However, I'm not entirely sure that's the correct way to look at it. (Please
let me know if my thinking was astray :)

Cheers,
Rob
 
P

Peter J. Holzer

Yes - I was referring specifically to ActivePerl, where 'perl -V:longsize'
is '4' on both the 32-bit and 64-bit versions.

Yes, but my point was that size of 'N' is independent of 'perl
-V:longsize'. Even on systems where the latter is 8, pack('N', ...)
still returns 4 bytes.

hp
 
S

Sisyphus

Peter J. Holzer said:
..

Yes, but my point was that size of 'N' is independent of 'perl
-V:longsize'. Even on systems where the latter is 8, pack('N', ...)
still returns 4 bytes.

Aaaah ... I understand (now). Thanks.

Cheers,
Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top