I don't think it's identical.  Casting to long truncates, which means you 
may have an answer which is off by one.

At 11:28 03/08/2002, Andi Gutmans wrote:
>I think this is a good question.
>I'm not quite sure that casting dval to long is the same as multiplying 
>the two longs.
>Anyone know the answer?
>
>Andi
>
>At 02:28 PM 7/31/2002 +0200, Stefan Esser wrote:
>>Hi,
>>
>>Could someone tell me why the Zend Engine calculates every multiplication
>>2 times???
>>
>>zend_operators.c:
>>
>>ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
>>{
>>...
>>         if (op1->type == IS_LONG && op2->type == IS_LONG) {
>>                 double dval = (double) op1->value.lval * (double) 
>> op2->value.lval;
>>
>>                 if ((dval > (double) LONG_MAX) || (dval < (double) 
>> LONG_MIN)) {
>>                         result->value.dval = dval;
>>                         result->type = IS_DOUBLE;
>>                 } else {
>>                         result->value.lval = op1->value.lval * 
>> op2->value.lval;
>>                         result->type = IS_LONG;
>>                 }
>>                 return SUCCESS;
>>
>>...
>>
>>should that be replaced with:
>>
>>result->value.lval = (long)dval;
>>
>>instead of calculating the multiplication again???
>>
>>
>>Stefan Esser
>>
>>
>>--
>>PHP Development Mailing List <http://www.php.net/>
>>To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to