CommandHelper

CommandHelper

46.5k Downloads

is_numeric() can mistake

LadyCailinBot opened this issue · 2 comments

commented

CMDHELPER-3017 - Reported by Алексей.Положенцев

Build #2822-

"console(is_numeric('1D'))" will return 'true' for some reason.
"console(is_numeric('D'))" will return 'false' though.

commented

Comment by PseudoKnight

Interesting. '1D' is basically saying it's a double. That means '1F' or '1.0F' also works as well as '1.01E-1'. I didn't expect that, but it makes sense. Some numbers output strings like that.

This would also affect is_integral in some cases.

commented

Comment by PseudoKnight

This also makes is_numeric(false) return true, because is_numeric is documented as "Returns false if the item would fail if it were used as a numeric value." So it's working as defined. (eg. false is 0, true is 1, etc)