Re: Re: cvs: php-src /ext/sybase_ct

From: Date: Sun, 16 May 2004 14:38:54 +0000
Subject: Re: Re: cvs: php-src /ext/sybase_ct
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-9874@lists.php.net to get a copy of this message
On Sat, 2004-05-15 at 20:11, Ard Biesheuvel wrote: [...LONG_MIN / LONG_MAX comparison] > Hi Timm, > > I think this code is broken on 64-bit archs, as doubles lack the > precision to accurately represent a 64-bit long. Also, comparing double > values with LONG_[MIN|MAX] is dangerous for the same reason. Ard, sorry, I don't have any 64-bit machines available to me:) Do you (or does anybody else) have one? If so, what does this print? -------------------------------------------------------------------------- #define LONG_MAX 2147483647L #define LONG_MIN (- LONG_MAX - 1) int main(int argc, char* argv) { printf("1) %s\n", (double)LONG_MAX + 1 > LONG_MAX ? "+OK" : "-ERR"); printf("2) %s\n", (double)LONG_MIN - 1 < LONG_MIN ? "+OK" : "-ERR"); } -------------------------------------------------------------------------- I thought this code was OK by looking at the following: Zend/zend_operators.c:#define DVAL_TO_LVAL(d, l) (l) = (d) > LONG_MAX ? (unsigned long) (d) : (long) (d) If it's not [OK], what alternatives exist? - Timm

« previous php.internals (#9874) next »