Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Subtracting Stringified Negative Numbers

by naikonta (Curate)
on Jun 22, 2007 at 04:23 UTC ( [id://622707]=note: print w/replies, xml ) Need Help??


in reply to Subtracting Stringified Negative Numbers

That's really strange. Are you sure that $n1 and $n2 are assigned with literal value as you do, and not from any external resources or inputs?

Update: Following your update, now we know that $n1 is splitted out from $some_string. But, where the heck this $some_string came from? It's the ultimate source of the data you need to tell so we know how is the data originally or initially the first time it arrives to the perl interpreter or your script. Don't emulate by literally assinging it to a variable if that's not actually the case since we'll just get nowhere.

$ cat diff.pl use strict; use warnings; my $n1 = '-933'; # the same result my $n2 = '-1039'; # without quotes my $diff = $n1 - $n2; print "diff: $diff\n"; $ perl diff.pl diff: 106 $ perl -V Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=linux, osvers=2.6.9-22.18.bz155725.elsmp, archname=i386-lin +ux-thread-multi uname='linux hs20-bc1-6.build.redhat.com 2.6.9-22.18.bz155725.elsm +p #1 smp thu nov 17 15:34:08 est 2005 i686 i686 i386 gnulinux '

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://622707]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-25 05:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found