[Phpwm] unsigning a numeric variable

Phil Beynon phil at infolinkelectronics.co.uk
Fri May 5 10:16:07 BST 2006

> On 5/4/06, Phil Beynon <phil at infolinkelectronics.co.uk> wrote:
> > Is there a quicker functional way to unsign a numeric variable,
> apart from
> > squaring it then taking the square root of the resultant?
> $startingval = -99999999;
> $newval = 0 - $startingval;

That's only going to work if it was made conditional, if($startingval < 0){}
which would be less efficient than my solution. Otherwise the resultant
would normally be negative.

All I'm trying to do here is catch any numeric negatives in a form
submission, which in reality shouldn't really ever occur. But since these
are pixel widths for a mogrify resize, as part of a system manager for
resizing previously uploaded pics that might be needing tweaking a bit,
entering a negative pixel value rates as 'bad' and causes execution
silliness. :-)

Good example though of the requirements of making applications idiot


Phil Beynon
Sales director

** http://www.diygear.com THE Online DIY Toolstore For DIY & Business
** Infolink Electronic Systems Ltd. http://www.infolinkelectronics.co.uk
** Professional Web Design & Cobalt Hosting Solutions
** Contact: Sales at infolinkelectronics.co.uk
** Tel / Fax 0121 458 4894 (office) 0121 441 3558 (home) 07801 548464

More information about the Phpwm mailing list