[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: checking for numeric chars



David,
if $char = to_char(to_number($char))
The idea is good but it will mislead if you get
decimals in the field $Char.
Say $char = 0.00
Then to_number of this would be 0.0000 ( Because SQR
store any number variable up to 32 decimals)
and when you use to_char to convert the 0.0000 the
result would be  get just 0 not 0.00.


Hope this helps

Arun


--- David Thompson-Hall
<david.thompson-hall@DOIT.WISC.EDU> wrote:
> Oops, sorry, here I thought I was asking a simple
> thing, and I wasn't clear...
>
> I want to check if a given character in a string is
> numeric.  So I am
> already looping thru the string and grabbing
> individual charactes, now I
> want to figure out if they are numeric...
>
> At 03:15 PM 2/11/02 -0700, Alan Ljungberg wrote:
> >Do you want to determine if only a single character
> is numeric then i would
> >evaluate if the ascii value is beween 048 and ,
> 057.  048 and , 057 are the
> >ascii values for 0 and 9 , if the acsii value is
> any value between the
> >character is numeric.  This will work for numeric
> characters in CHAR
> >fields.
>
> This is what I want to do - but I'd rather not check
> against ASCII codes,
> this seems cryptic and hard to maintain.
>
> The idea I had was
>
> if $char = to_char(to_number($char)
>
> Someone suggested in private email I use
> translate...
>
> if Translate($char,'1234567890','X') = 'X'
>    ! then char is numeric
> else
>    ! not numeric
> end-if
>
> this is certainly a good use of translate...
>
> so which one is "better"?  Quicker?  more elegant?
>
> any other ideas?
>
> DTH
>
> David Thompson-Hall
>    1210 W. Dayton St.
> Programmer/Analyst
>    Madison, WI 53706
> Apps Tech/Operational Support Apps
>    608/265-9571
> Div of Info Technology (DoIT)
> University of Wisconsin-Madison
david.thompson-hall@doit.wisc.edu


__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com