integer division

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

>I download Euphoria 1.5a and a tutorial yesterday.  Now I have a
>question: Does Euphoria have a version of the Qbasic "\" operator?

Integer division is faster than floating point, obviously. But wouldn't
the interpreter have to verify that both values are integers, and then
convert them if they aren't? It seems to me that this would take longer
than just doing a floating-point divide. Especially on today's
processors that are so floating-point enhanced. Can anyone explain this
to me.

At any rate a forced integer divide would be out of place in Euphoria.
It would return us to thinking about our individual numbers as integer,
floats, longs, etc... The great thing about Euphoria is that it allows
you to ignore such isses, unless you are doing power programming (read:
games). Also, I am sure that the processor requires integer values for
the operands in such as function, so the Euphoria interpreter will still
need to check (and possibly convert) the atoms to see if they are
integers.

Of course maybe all you want is to do a integer-divide for the sake of
getting just integers. In that case...

        function int_divide(atom operand1, atom operand2)
                return floor(operand1/operand2)
        end function

This is probably not that fast, but it does give a result that is always
an integer.

John DeHope

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

Search



Quick Links

User menu

Not signed in.

Misc Menu