|
Post by tsh73 on Apr 13, 2018 19:47:58 GMT
>> OK, so a problem if the number is too long: That couldn't be helped Double could contain only so much digits (16) They could be viewed say via Scientific USING functionAs for function, I think supporting +-3 (or even -2e+-+3 ) is really too much. No sane person would ever write that way. Or would it? I found that it considers "5e" to be a number - should it? and somehow "2e3.4" too, though code has message "Failed decimal past e." - obviously this check failed.
|
|
|
Post by B+ on Apr 13, 2018 20:58:58 GMT
>> OK, so a problem if the number is too long: That couldn't be helped Double could contain only so much digits (16) They could be viewed say via Scientific USING functionAs for function, I think supporting +-3 (or even -2e+-+3 ) is really too much. No sane person would ever write that way. Or would it? I found that it considers "5e" to be a number - should it? and somehow "2e3.4" too, though code has message "Failed decimal past e." - obviously this check failed. RE: Numbers too long, at least they are numbers user might have intended. RE: counting +- strings, I believe card counters of Black Jack use some sort of +- system and that is pretty sane. Now that we know we can do it and it will be evaluated correctly, maybe some application will come up for it.? RE: 10e comes out as 10, eh! OK RE: 10e3.4 comes out as 10000 which is wrong and should be flagged as not the number user intended (but what is e3.4???), no decimals should appear after an e so user had typo, probably... I am thinking the whole or main purpose of this isNumber(test$) function is to check is to see whether VAL(test$) can be used with intended results or not. BTW, I have enjoyed challenge of getting this thing to work but wonder what rnbw is thinking about all this?
|
|
|
Post by jarych on Jun 30, 2019 2:56:15 GMT
I found this topic very late. Looking at B+'s code example posted on April 18, 2018, 1:09PM, his example appears to make the best sense because the simple decision structure is clean.
Looking back at the original quoted example, I am sure it was tested first and found to be good, but the decision structure seems off. That looks like the stucturing was supposed to be an IF-THEN-ELSE type. Maybe I will check it myself in JB and see what will happen. The program looks like, if the user does not enter anything and just clicks "ENTER" key of the keyboard, that would be bad input or not a number.
I too found that sometimes VAL() does something odd regarding the presence of alphabet characters. On the other hand, the use of INSTR() that B+ shows is good; he also helped with this function a few days ago on another recent topic.
|
|
|
Post by jarych on Jun 30, 2019 8:06:59 GMT
That first posted program example in fact was wrong, and does not work correctly.
Here! This one is much much so much better:
[start] print "Give me some input. It must be a number." input test$
if test$="" then goto [done]
if str$(val(test$)) = test$ then print "Good. Input is a number" else print "No. Not a number" end if
goto [start]
[done] end
|
|