Re: Should to_number return a sequence?
- Posted by xecronix 1 week ago
- 460 views
petelomax said...
Your is_number("-") crashes.
Thank you for the bug report. I'm appreciative for sure. I made a fix and a test. The wiki is updated. I'll look at all your suggestions. In the meantime, this was the stopgap I applied.
-- we'll skip the sign if it has one if find(maybe[i], "+-") then i += 1 end if -- The index might have just moved. Make sure there is at least 1 more character to consider. if i > length(maybe) then -- <<-- New code return 0 end if
$ eui is_number.ex Testing for FALSE (0): Testing is_number function with input [ ] result: [0] Testing is_number function with input [.] result: [0] Testing is_number function with input [-] result: [0] Testing is_number function with input [+] result: [0] Testing is_number function with input [..] result: [0] Testing is_number function with input [.-] result: [0] Testing is_number function with input [.+] result: [0] Testing is_number function with input [-.] result: [0] Testing is_number function with input [+.] result: [0] Testing is_number function with input [0..] result: [0] Testing is_number function with input [.0.] result: [0] Testing is_number function with input [--] result: [0] Testing is_number function with input [++] result: [0] Testing is_number function with input [1 4] result: [0] Testing is_number function with input [A] result: [0] Testing is_number function with input [-a] result: [0] Testing is_number function with input [+a] result: [0] Testing is_number function with input [-.a] result: [0] Testing is_number function with input [+.a] result: [0] Testing is_number function with input [.a] result: [0] Testing is_number function with input [1a] result: [0] Testing is_number function with input [.1a ] result: [0] Testing is_number function with input [] result: [0] Testing for TRUE (1): Testing is_number function with input [0] result: [1] Testing is_number function with input [0.] result: [1] Testing is_number function with input [.0] result: [1] Testing is_number function with input [-.0] result: [1] Testing is_number function with input [+.0] result: [1] Testing is_number function with input [0.0] result: [1] Testing is_number function with input [-0.0] result: [1] Testing is_number function with input [+0.0] result: [1] Testing is_number function with input [123] result: [1] Testing is_number function with input [123.] result: [1] Testing is_number function with input [.123] result: [1] Testing is_number function with input [-.123] result: [1] Testing is_number function with input [+.123] result: [1] Testing is_number function with input [123.123] result: [1] Testing is_number function with input [-123.123] result: [1] Testing is_number function with input [+123.123] result: [1] Testing is_number function with input [00032] result: [1] Testing is_number function with input [-00032] result: [1] Testing is_number function with input [+00032] result: [1] Testing is_number function with input [00032.000] result: [1] Testing is_number function with input [-00032.050] result: [1] Testing is_number function with input [+00032.0] result: [1] What would Euphoria do?? atom d = atom(to_number(test_str, -1)) Testing for FALSE (0): What would Euphoria do with input [ ] result: [0] What would Euphoria do with input [.] result: [0] What would Euphoria do with input [-] result: [0] What would Euphoria do with input [+] result: [0] What would Euphoria do with input [..] result: [0] What would Euphoria do with input [.-] result: [0] What would Euphoria do with input [.+] result: [0] What would Euphoria do with input [-.] result: [0] What would Euphoria do with input [+.] result: [0] What would Euphoria do with input [0..] result: [0] What would Euphoria do with input [.0.] result: [0] What would Euphoria do with input [--] result: [0] What would Euphoria do with input [++] result: [0] What would Euphoria do with input [1 4] result: [0] What would Euphoria do with input [A] result: [0] What would Euphoria do with input [-a] result: [0] What would Euphoria do with input [+a] result: [0] What would Euphoria do with input [-.a] result: [0] What would Euphoria do with input [+.a] result: [0] What would Euphoria do with input [.a] result: [0] What would Euphoria do with input [1a] result: [0] What would Euphoria do with input [.1a ] result: [0] What would Euphoria do with input [] result: [0] Testing for TRUE (1): What would Euphoria do with input [0] result: [1] What would Euphoria do with input [0.] result: [1] What would Euphoria do with input [.0] result: [1] What would Euphoria do with input [-.0] result: [1] What would Euphoria do with input [+.0] result: [1] What would Euphoria do with input [0.0] result: [1] What would Euphoria do with input [-0.0] result: [1] What would Euphoria do with input [+0.0] result: [1] What would Euphoria do with input [123] result: [1] What would Euphoria do with input [123.] result: [1] What would Euphoria do with input [.123] result: [1] What would Euphoria do with input [-.123] result: [1] What would Euphoria do with input [+.123] result: [1] What would Euphoria do with input [123.123] result: [1] What would Euphoria do with input [-123.123] result: [1] What would Euphoria do with input [+123.123] result: [1] What would Euphoria do with input [00032] result: [1] What would Euphoria do with input [-00032] result: [1] What would Euphoria do with input [+00032] result: [1] What would Euphoria do with input [00032.000] result: [1] What would Euphoria do with input [-00032.050] result: [1] What would Euphoria do with input [+00032.0] result: [1]