[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fun-O Basic Edition Compiler
Bruce Hoult wrote:
>>>How can you do it for multiplication, other than by dividing afterwards
>>>and comparing, or pre-classifying the operands?
>>>
>>Well, sometimes you can preclassify at compile time...
>>
>
> Yes, if one operand is a constant, k, then you can test the abs() of the
> other against 2^31/k.
More than that. I don't know if GD does this, but some compilers
attempt to classify varibles by range. So if you know that a variable y
is between 0 and max and x * max would not overflow, then x * y can't
overflow either.