Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread isFloat and isInt functions
Sat, Oct 30 2021 4:28 PMPermanent Link

Richard Harding

Wise Nutrition Coaching

The isFloat and isInt functions returns incorrect results.

isInt(‘0a’) = true
isFloat(0.0a’) = true

The example in the documentation, (X := IsInt('10.20');  // X is False), also returns true.
Mon, Nov 1 2021 7:24 AMPermanent Link

erickengelke

Avatar

Richard Harding wrote:

The isFloat and isInt functions returns incorrect results.

isInt(‘0a’) = true
isFloat(0.0a’) = true

The example in the documentation, (X := IsInt('10.20');  // X is False), also returns true.
EWB Programming Books and Component Library
http://www.erickengelke.com
Mon, Nov 1 2021 7:27 AMPermanent Link

erickengelke

Avatar

erickengelke wrote:

> isInt(‘0a’) = true

The code uses parseInt /parseFloat, which stop at the first non-numeric number.

so isInt('G') would probably fail, but you can see the logic because StrToInt('12a') returns 12.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Mon, Nov 1 2021 4:10 PMPermanent Link

Richard Harding

Wise Nutrition Coaching

Greetings Erick.

Yes - I know the reason why this happens.

For normal people, '0a' is not an integer and '0.0a' is not a float.

It makes the functions unusable when validating input.

Richard
Mon, Nov 1 2021 9:55 PMPermanent Link

erickengelke

Avatar

Richard Harding wrote:

> Yes - I know the reason why this happens.

I figured you would. Smile  


>For normal people, '0a' is not an integer and '0.0a' is not a float.
>It makes the functions unusable when validating input.

Very true.

I think what it tells you is only that StrToInt will return an integer answer without raising an exception, but possibly not the right one as you showed.  Not necessarily a useful result.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Mon, Nov 29 2021 6:37 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Richard,

<< The isFloat and isInt functions returns incorrect results. >>

I'll check this out and see what's involved for a fix.

Tim Young
Elevate Software
www.elevatesoft.com
Image