Check if number is an integer

Yes, but we have blocks to convert to hex and back. Unfortunately, there is no hex-only keyboard. there is an alphanumeric keyboard and you can enter letters from outside of hex. When we substitute invalid data for the hex to dec conversion, the block will return an error. If we already have hex in math blocks, it would be useful to have a block checking if the text is in the range 0-9 and A-F. Yes I know, we can do it in blocks, and you can also check with blocks if a number is an integer or a decimal number. :grin:.

1 Like

It's a very great solution. Works the same as the previous one with much less code.

Actually, upon reviewing the code the is number block does have a hexadecimal variant and it has been in the system since 2015.

1 Like

It really is :flushed:. I don't think I ever checked this block by opening its functions :thinking:.

image

Is there a situation when x is not a number yet still equals 0 in the formula ?

( I agree that your blocks are more concise....)

Sure, if I pass foobar as an input :slight_smile:

I concede, either input textbox to numbers only or use isNumber block, but:

remainder of "foobar" / 1 does not equal 0

1 Like

Also, a comma used as a period (full stop) is not catered for - yet most of Europe and some industries world-wide use the comma (aircraft industry being one, which is where the use of a comma started) .

Another negative to that approach is that once your values are large/small enough, App Inventor will switch to using scientific notation, so even though there's a period present in the printed representation that doesn't imply that "integer-ness" of the value. For example, 1.234567E10 is an integer but 1.234567E5 is not.

Sounds like a rock-solid case for updating is number? :innocent:

We can infer from the foobar sample that the and block is lazy; If the first input is false, the second input is not evaluated, hence the lack of an error on foobar.

@ABG - I was referencing my example that does not test isNumber...

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.