To test for a negative:if ($fraction =~ /^((-) ?)?((\d+) )?(\d+) ?\/ ?(\d+)$/) { $fraction = ($2 ? -1 : 1) * ($4 + $5 / $6); }
if ($fraction =~ /^((-) ?)?((\d+) )?(\d+) ?\/ ?(\d+)$/ && $2) { #run if negative... }
In reply to Re: How do I detect if a number has a minus sign?
by TedPride
in thread How do I detect if a number has a minus sign?
by algonquin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |