Re: Possible bug (sorry if it's a repeat)

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

JJProg at CYBERBURY.NET wrote:
>It seems that Euphoria doesn't generate an error when an integer goes
>out of bounds like so:
>
>constant MAX_INTEGER = 1073741823
>procedure display_integer(integer z)
>    ? z
>end procedure
>integer x, y
>x = MAX_INTEGER
>x += 1 -- No error
>x = MAX_INTEGER
>x = x + 1-- No error
>y = x -- No error
>? integer(y) -- Displays 0
>display_integer(y) -- Error here
>
>I'm not sure whether this is a bug or it is supposed to happen, but it
>seems like a bug considering:
>
>constant MAX_INTEGER = 1073741823
>type int(object x)
>        return integer(x)
>end type
>int x
>x = MAX_INTEGER
>x += 1 -- This causes an error

!!!

This does indeed seem to be an bug. And an intriguing one at that...

The docs detail an integer as a 31-bit signed number, making MAX_INTEGER
the maximum value an integer can have. Adding one to it (the first 'x += 1'
AND 'x = x + 1') should result in an error. And one would think that
passing an integer variable to the 'integer' typecheck function would
always return a 1. The 'display_integer' function bombed, like it should
have (based soley on y's value). Your second example also behaved
correctly.

Only Rob will be able to explain the 'why' of all this though (and be able
to fix it...)


Rod Jackson

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

Search



Quick Links

User menu

Not signed in.

Misc Menu