value() misleading?

new topic     » topic index » view thread      » older message » newer message

-- Some time ago I asked if in certain cases value() returns
-- misleading results. Run the following program and let me know
-- your opinion about the results.
-- Thanks, Rolf
--
include get.e
    sequence s, sval
    s = {}
    for i = 1 to 9 do                   -- define 9 + 9 strings
        s = append(s, (48+i) & (96+i))
    end for
    for i = 1 to 9 do
        s = append(s, (48+i) & (64+i))
    end for
    puts(1,"Look at these value()-returns:\n\n")
    for i = 1 to 18  do
        sval = value(s[i])                      -- call value()
            puts(1,"value(\""&s[i]&"\"): ")
        if    sval[1] = GET_FAIL    then        -- check error condition
            printf(1,"{GET_FAIL,%d}", sval[2])      -- print result
        elsif sval[1] = GET_SUCCESS then        -- check error condition
            printf(1,"{GET_SUCCESS,%d}", {sval[2]}) -- print result
        else
            printf(1,"{UNKNOWN,%d}", {sval[2]}) -- should never happen
        end if
        puts(1,"\n")
    end for

    puts(1,"\n\nI guess, ALL value-returns should give {GET_FAIL,0} for
ALL \n")
    puts(1,"strings do NOT represent legaly written numbers!\n")
    puts(1,"Any remarks or comments?\n Rolf\n")

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu