Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 4 of 4 total |
IsNumber function, NaN and IsNaN. |
Wed, Oct 30 2013 5:33 AM | Permanent Link |
E.B | Hello,
I'm trying to code an "IsNumber(S:String):Double" function with EWB. First idea is testing every characters in S. But EWB seems to have an interesting way to deal with not-a-number strings with FloatToStr. If S contains "," it is rouding to an integer. If S contains "." it is rouding to a double. If S's not a number it is set to "NaN". So testing if FloatToStr return "NaN" or not is a way to test if it is a valid float number. But how can I test if a double is equal to NaN ? I didn't see "IsNan" function and compiler refuse "if x=NaN then". Regards. F. |
Tue, Nov 5 2013 3:24 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eric,
<< I'm trying to code an "IsNumber(S:String):Double" function with EWB. First idea is testing every characters in S. But EWB seems to have an interesting way to deal with not-a-number strings with FloatToStr. >> EWB doesn't actually perform the conversion - the conversion is performed by the Javascript runtime library. << If S contains "," it is rouding to an integer. If S contains "." it is rouding to a double. If S's not a number it is set to "NaN". So testing if FloatToStr return "NaN" or not is a way to test if it is a valid float number. But how can I test if a double is equal to NaN ? >> Could you please post the code that you're using ? Thanks, Tim Young Elevate Software www.elevatesoft.com |
Sun, Nov 10 2013 4:09 AM | Permanent Link |
E.B | Function Isnum(S:String):Boolean;
Var X: double; Begin X:=StrToFloat(S); Now I want to test if S is "Not a Number" (NaN), Tim. end; I solved the problem writing a lot a test (S in ['0'..'9','-','+','.'] etc.) But I would to use a IsNum function that is using StrToFloat function. "Tim Young [Elevate Software]" wrote: Eric, << I'm trying to code an "IsNumber(S:String):Double" function with EWB. First idea is testing every characters in S. But EWB seems to have an interesting way to deal with not-a-number strings with FloatToStr. >> EWB doesn't actually perform the conversion - the conversion is performed by the Javascript runtime library. << If S contains "," it is rouding to an integer. If S contains "." it is rouding to a double. If S's not a number it is set to "NaN". So testing if FloatToStr return "NaN" or not is a way to test if it is a valid float number. But how can I test if a double is equal to NaN ? >> Could you please post the code that you're using ? Thanks, Tim Young Elevate Software www.elevatesoft.com |
Thu, Nov 14 2013 3:08 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eric,
<< Now I want to test if S is "Not a Number" (NaN), Tim. >. Use this: uses WebDOM; Function Isnum(S:String):Boolean; Var X: double; Begin X:=StrToFloat(S); if isNaN(X) then Result:=False else Result:=True; end; Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Tuesday, May 7, 2024 at 06:25 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |