Re: Should to_number return a sequence?

new topic     » goto parent     » topic index » view thread      » older message » newer message
xecronix said...
irv said...

Why shouldn't it return a number or NaN on failure?

Or does NaN not exist in Eu?

I can't speak definitively to whether or not NaN exists in Euphoria or Phix. But, I can say, I haven't seen that yet... sort of.

Phix\builtins\VM\pprntfN.e, procedure init_2() said...
--      inf = 1e300*1e300 
        #ilASM{ fld1 
                fldz 
                fdivp 
            [32] 
                lea edi,[inf] 
            [64] 
                lea rdi,[inf] 
            [] 
                call :%pStoreFlt } 
 
        -- Erm, this one is a bit bizarre... 
        -- On the one hand it seems RDS Eu does not support nan properly, but then it somehow does... 
        -- If you try testing for nan, it seems to go all pear-shaped, but avoiding the tests 
        --  seems to make it happy again, and yet print "nan" and "inf" like a good little boy... 
        -- Of course, you shouldn't be using this code on RDS Eu anyway. 
        -- 
--/**/  nan = -(inf/inf)        --/* Phix 
        nan = 3.245673689e243   --   RDS --*/ 

So that's how I've been creating nan for the past 15 years or more, but I cannot remember why I replaced 1e300*1e300 and
I'm sure I still use that method in a few other places (including 64-bit) - it might very well have been a multithreading issue.
I suspect there's a fairly strong probability that specific value for nan only works on 32-bit RDS Eu.

xecronix said...
-- Phix 
to_number("x") -- this returns a sequence.  Which is Not a Number. 
-- Phix 
to_number("x",0) -- this returns 0.  Which is a Number. 

smile

PS: I would have loved to have been a fly on the wall and see how you found to_number in the Euphoria docs after failing to find it in Phix.chm...
PPS: At least in my book, to_number() [optionally/sometimes] delivering a typecheck is [often] a perfectly good debugging technique.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu