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
math(n) 							 Tcl Math Library							   math(n)

__________________________________________________________________________________________________________________________________________________

NAME
math - Tcl Math Library SYNOPSIS
package require Tcl 8.2 package require math ?1.2.5? ::math::cov value value ?value ...? ::math::integrate list of xy value pairs ::math::fibonacci n ::math::max value ?value ...? ::math::mean value ?value ...? ::math::min value ?value ...? ::math::product value ?value ...? ::math::random ?value1? ?value2? ::math::sigma value value ?value ...? ::math::stats value value ?value ...? ::math::sum value ?value ...? _________________________________________________________________ DESCRIPTION
The math package provides utility math functions. Besides a set of basic commands, available via the package math, there are more specialised packages: o math::bigfloat - Arbitrary-precision floating-point arithmetic o math::bignum - Arbitrary-precision integer arithmetic o math::calculus::romberg - Robust integration methods for functions of one variable, using Romberg integration o math::calculus - Integration of functions, solving ordinary differential equations o math::combinatorics - Procedures for various combinatorial functions (for instance the Gamma function and "k out of n") o math::complexnumbers - Complex number arithmetic o math::constants - A set of well-known mathematical constants, such as Pi, E, and the golden ratio o math::fourier - Discrete Fourier transforms o math::fuzzy - Fuzzy comparisons of floating-point numbers o math::geometry - 2D geometrical computations o math::interpolate - Various interpolation methods o math::linearalgebra - Linear algebra package o math::optimize - Optimization methods o math::polynomials - Polynomial arithmetic (includes families of classical polynomials) o math::rationalfunctions - Arithmetic of rational functions o math::roman - Manipulation (including arithmetic) of Roman numerals o math::special - Approximations of special functions from mathematical physics o math::statistics - Statistical operations and tests BASIC COMMANDS
::math::cov value value ?value ...? Return the coefficient of variation expressed as percent of two or more numeric values. ::math::integrate list of xy value pairs Return the area under a "curve" defined by a set of x,y pairs and the error bound as a list. ::math::fibonacci n Return the n'th Fibonacci number. ::math::max value ?value ...? Return the maximum of one or more numeric values. ::math::mean value ?value ...? Return the mean, or "average" of one or more numeric values. ::math::min value ?value ...? Return the minimum of one or more numeric values. ::math::product value ?value ...? Return the product of one or more numeric values. ::math::random ?value1? ?value2? Return a random number. If no arguments are given, the number is a floating point value between 0 and 1. If one argument is given, the number is an integer value between 0 and value1. If two arguments are given, the number is an integer value between value1 and value2. ::math::sigma value value ?value ...? Return the population standard deviation of two or more numeric values. ::math::stats value value ?value ...? Return the mean, standard deviation, and coefficient of variation (as percent) as a list. ::math::sum value ?value ...? Return the sum of one or more numeric values. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
math, statistics CATEGORY
Mathematics math 1.2.5 math(n)
All times are GMT -4. The time now is 07:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy