Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
Operating System - Tru64 Unix
cancel
Showing results for 
Search instead for 
Did you mean: 

How to truncate addition result nbr that has more than 15 digits.

perl
Occasional Visitor

How to truncate addition result nbr that has more than 15 digits.

Hi,

I have a Perl script that adds numbers grater than 15 digits using this code:
$vol_hash = ($vol_hash + $data[3]);
when I use substr($vol_hash + $data[3]),0,15);

the result displays:
999999999999992 instead of 299999999999999
or 2.99999999999999
this is adding 999999999999990 3 times.

If I try to embed the following Oracle sql in the perl script, it does not display anything:
$vol_rec_tot = $dbh->prepare("select
substr(sum(volume), 0, 15), company_id
from t_volume_summary
where date is null and
element_id <> 'CANCELED'
group by ID");
Running the sql in Oracle I get the expected result. what is the sintax in Perl?
I appreciate your help, Thanks
1 REPLY
perl
Occasional Visitor

Re: How to truncate addition result nbr that has more than 15 digits.

correction:
$vol_rec_tot = $dbh->prepare("select
substr(sum(VOLUME), 0, 15), ID
from t_volume_summary
where DATE is null and
ELEMENT_ID <> 'CANCELED'
group by ID");