Sponsored Content
Top Forums Shell Programming and Scripting How to handle 64 bit arithmetic operation at 32 bit compiled perl interpreter?H Post 302669405 by rrd1986 on Wednesday 11th of July 2012 02:30:34 AM
Old 07-11-2012
How to handle 64 bit arithmetic operation at 32 bit compiled perl interpreter?H

Hi,
Here is the issue. From the program snippet I have Base: 0x1800000000, Size: 0x3FFE7FFFFFFFF which are of 40 and 56 bits. SO I used use bignum to do the math but summing them up I always failed having correct result.

Code:
perl interpreter info,
perl, v5.8.8 built for i386-linux-thread-multi

Program snippet,

Code:
use bignum qw/hex/;

$x ="SAD_MISS_REGION:Base:Size
SAD_MISS_REGION:0x100000000:0x100000000
SAD_MISS_REGION:0x400000000:0x400000000
SAD_MISS_REGION:0x1800000000:0x3FFE7FFFFFFFF";

while ( $x =~ /SAD_MISS_REGION:(.+):(.+)/g ) {

$p = $1; $q = $2;
$phex = hex($1); $qhex = hex($2);

}

print "\n\n\n\nBase: $p, Size: $q \n";
print "\n\n\n\nBaseinDecimal: $phex, SizeinDesimal: $qhex \n";

$z = $phex + $qhex;
print "Z has summed up value:  $z\n";

$zhex = unpack "H*", $z;
#$zhex = uc(sprintf("%x\n", $z));
print "Hexadecimal number of Z: ", $zhex, "\n";

output:

Base: 0x1800000000, Size: 0x3FFE7FFFFFFFF




BaseinDecimal: 103079215104, SizeinDesimal: 1125796827627519
Z has summed up value:  1125899906842623
Hexadecimal number of Z: 31313235383939393036383432363233

------------------------------------------------------------

Math::BigInt seems to be a solution but i dont have it installed at my remote machine. Need a work around. Please help....


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by zaxxon; 07-11-2012 at 03:34 AM.. Reason: code tags, see PM. Should know that with 18 posts...
 

4 More Discussions You Might Find Interesting

1. Programming

copying or concatinating string from 1st bit, leaving 0th bit

Hello, If i have 2 strings str1 and str2, i would like to copy/concatenate str2 to str1, from 1st bit leaving the 0th bit. How do i do it? (2 Replies)
Discussion started by: jazz
2 Replies

2. Red Hat

can not reboot : PCI: Unable to handle 64-bit address space for

Hello, every one, I tried to install redhat linux enterprise server version 4 (ES4) on the my system with the following configuration Pentium core 2 duo 2.66 E 6750 Intel DG33FB motherboard 160Gb Segate hard disk (SATA) 1024 mb (1GB) DDR2 TRAN RAM Lg DVD/Cd WR BUT AM GETTING... (0 Replies)
Discussion started by: moinkhan31
0 Replies

3. Red Hat

boot the 32 bit kernel on a 64 bit PPC Linux machine?

Hi all, I'm looking to cover a corner case for an upcoming test cycle. Is there a way to boot a RedHat Advanced Server 4 (update 3) installed on a Power PC machine to use a 32 bit kernel? This would be similar to what is done here -> https://www.unix.com/aix/26204-aix-platform.html I've done... (0 Replies)
Discussion started by: philrau
0 Replies

4. Windows & DOS: Issues & Discussions

Which version of Windows Vista to install with a product key? 32-bit or 64-bit?

Hello everyone. I bought a dell laptop (XPS M1330) online which came without a hard drive. There is a Windows Vista Ultimate OEMAct sticker with product key at the bottom case. I checked dell website (here) for this model and it says this model supports both 32 and 64-bit version of Windows... (4 Replies)
Discussion started by: milhan
4 Replies
copysignd64(3M) 														   copysignd64(3M)

NAME
copysignd64(), copysignd128(), copysignd32() - decimal copysign functions SYNOPSIS
DESCRIPTION
The function returns x with its sign changed to the sign of y. is a version of it takes arguments and returns a result. is a version of it takes arguments and returns a result. These math functions are supported for HP-UX 11i Version 3 September 2008 Update and forward. USAGE
To use any of these functions, compile with the option. Make sure your program defines and then includes Link in the math library by specifying or on the linking command line. For more information, see the at the following site: RETURN VALUE
These functions simply copy the bit encoding of x, replacing the sign bit with the sign bit of y. These functions raise no exceptions. ERRORS
No errors are defined. SEE ALSO
fabsd64(3M), fpclassify(3M), remainderd64(3M), scalbnd64(3M), signbit(3M), math(5). STANDARDS CONFORMANCE
These functions conform to ISO/IEC TR 24732, "Extension for the programming language C to support decimal floating-point arithmetic". HP Integrity Server Only copysignd64(3M)
All times are GMT -4. The time now is 04:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy