On 22 Jan 2006, at 11:24, ik wrote:
val(x,code);
result:=(code=0) and (posexset(['+','-'],x)=0)
would already do. (untested from memory)
And why is that better ?
Because it reuses existing code (although the above could even be
made shorter by using TryStrToInt or so). Reusing existing code is
pretty much always better, because it improves maintainability,
reduces the chance to bugs and keeps the code size smaller.
I do a loop and see if I only have the valid
chars or stop. What happen if I have a number with 20 or 50 chars
based ? I only want to check if it contains a valid number chars, not
to actually convert it to anything (no one promise you that you can
convert it to any existed type!).
I really don't think this is something which is needed in an rtl unit.
Jonas
_______________________________________________
fpc-devel maillist - [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel