At 19:58 05-09-01, Gavin Sherry wrote:
On Wed, 5 Sep 2001, Zeev Suraski wrote:
In what cases do you see a problem with that? If (d) is bigger than
LONG_MAX, than you're screwed anyway.
I presume you are refering to my proposed hack? Perhaps a little more
detail =).
Nope :) I was actually referring to the way the code looks like right now.
If the type of either operand is greater than long, it cannot be demoted
(from double) without overflowing lval and giving unexpected results.
But when you overflow an integer, you get unexpected results. The only thing this code does is that in certain cases, where the lval would have been overflown and populated with meaningless info, instead, it populates it as if it's an unsigned long. If you use this information bitwise, then it's useful.
Instead, the relevant operations could be performed on unsigned longs,
with the result being cast to the most appropriate type (double or
long) based on whether op1 & op2 <= LONG_MAX.
Can you give an example of something that doesn't work with the way the code is currently?
Zeev