this might be a feature request or there might be a quick work around that is not obvious to me.
I just found out that there is now a NaN-value in PB. That's awesome.
So why is Val("not a number") not NaN?
Val() is older than NaN in PB, so I understand that it is not changed so older codes don't suddenly break (then again, my old 2D games broke, too)
But could there be a flag added or something?
What's your way of determining whether you just a number or not?
Code: Select all
Define test1.s, test2.s, test3.s
test1 = "33.5"
test2 = "0"
test3 = "string"
Debug ValD(test1) ;33.5
Debug ValD(test2) ;0
Debug ValD(test3) ;0 - should be NaN, imho?
So currently I'm reading strings and configured my input file in such a way, that "NaN" is written there.
I read a string, check if it's "NaN" and if not, I use Val(). Otherwise I assign NaN to the variable and later use IsNaN().
But if for some reason the file contains "?" or "XYZ", it will show as a 0, which is not something that I want. I want a clear way to distinguish between "0" and "whatever".
The only way I could think of that works for all strings would be to check if Ucase = LCase. This is true for numbers (other than exponentials) and false for strings. And I'd have to do this check everytime I read a 0-value