SammaySarkar wrote:@PeterH: a user function can have at most 11 arguments.
ed. also, any particular reason for the region-dependant $ret? Why not just "-2147483648" or hextodec('0x80000000') ?
btw, added both to UDF exchange.
Oh - double error
Don't want hextodec() for each call, no need to always recalculate. So not converting is best.
But being lazy I used calculator to convert hex to dec, and copied the result - including the dots
1
Now: without quotes they are decimal points
so I added quotes, thinking it's OK
2
For sure you are right:
Code: Select all
$ret = -2147483648; // smallest 32bit: x'80000000'
would have been what I wanted!
@FluxTorpedoe
I think your version can be OK for private use - but as it uses unusual parameters (i.e. not multiple parameters, but one parameter with a list of values, so must be called different) I wouldn't offer it as common - at least without a lot of hints for this situation.
And for an often used, but only once coded function I think that some lines more for "common handling" are OK.
By the way: I'm surprised by your "missing initialization" of $ret...
It seems for un-initialized $ret it's a string compare - where '$ret' is smaller than '1' and '-1'. So the result is correct.
(This is: the character '$' is less than '+', '-', and all numeric digits.)