Solved

How do I multiply negative number with Perl?

Posted on 2003-11-23
3
932 Views
Last Modified: 2013-12-25
I need to multiply a variable that contains a negative value by negative one.  Such as $test=(-1*$amount) where amount is negative.  I can't even get print "Test (-1*$amount)"; to work.  This prints: -1*-300.  
0
Comment
Question by:Shearer-Services
3 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 25 total points
ID: 9807635

Either do

$test = -1 * $amount;
print "$test\n";

or

print -1 * $amount , "\n':

0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 25 total points
ID: 9808762
 $test=(-1*$amount) ;
should work.
so would
  $test = -$amount;

  print "Test (-1*$amount)";
will just print the "Test (-1*" litterally
perhaps you meant
  print "Test", -1*$amount,"\n";
0
 

Author Comment

by:Shearer-Services
ID: 9810319
Despite my typo, you both helped answer the question.  Thanks
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to dynamically set the form action using jQuery.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now