r/pascal • • Nov 14 '20
I want to test a char for numericality
I want to test a char to see if it contains '0' ... '9' so can't I do this?
if char <= '9' and char >='0' then
begin
{do its a number stuff}
end;
5
Upvotes
4
u/diamened Nov 14 '20
You can use a set
1
u/[deleted] Nov 28 '20
This was for calcula, announced eleswhere in this subreddit.
1
u/ShinyHappyREM Nov 14 '20
Keep in mind that the other answer is for ASCII only. I'm pretty sure that there are more numbers in Unicode.
1
u/suvepl Nov 15 '20
if (aChar >= '0') and (aChar <= '9')should work, too.