Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25050 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43999 invoked by uid 1010); 29 Jul 2006 09:46:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 43984 invoked from network); 29 Jul 2006 09:46:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jul 2006 09:46:59 -0000 X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 209.142.136.51 neville-out.centurytel.net FreeBSD 4.6-4.9 Received: from ([209.142.136.51:3932] helo=neville-out.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id 20/00-43744-98E2BC44 for ; Sat, 29 Jul 2006 05:46:53 -0400 Received: from msa2-mx.centurytel.net (msa2-mx.centurytel.net [209.142.136.132]) by neville-out.centurytel.net (8.13.7/8.13.7) with ESMTP id k6T9kFjt025090 for ; Sat, 29 Jul 2006 04:46:29 -0500 (CDT) Received: from pc1 (207-119-216-12.dyn.centurytel.net [207.119.216.12]) by msa2-mx.centurytel.net (8.13.6/8.13.6) with SMTP id k6T9jnck026702; Sat, 29 Jul 2006 04:45:49 -0500 Message-ID: <00ca01c6b2f3$c6b6bea0$0201a8c0@pc1> To: , "Michael Wallner" References: <00c601c6b095$a1a2e220$0201a8c0@pc1> <010601c6b169$225b9eb0$0201a8c0@pc1> <6E.DD.23194.071B8C44@pb1.pair.com> <016401c6b17e$027908c0$0201a8c0@pc1> <19.E0.23194.CE2C8C44@pb1.pair.com> <00cd01c6b21e$c3956a30$0201a8c0@pc1> Date: Sat, 29 Jul 2006 04:45:50 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Subject: Re: [PHP-DEV] dec*(), *dec(), base_convert() and negative numbers From: php_lists@realplain.com ("Matt W") Hi again, OK, after my last message, I found when the dec*() functions started converting to unsigned long (Bug #6761). To make dechex(~8) etc. work. Now I know that behavior can't change. :-) Hopefully this is my last e-mail about this, if I can please find out about 2 simple things: 1) How should a negative *double*, whether it's < LONG_MIN or typecast (double) -123, be handled? *) Continue converting to long/unsigned long, like now? *) Use absolute value? (Only if double!) Either way, base_convert() should continue to use absolute value for all numbers, I assume. 2) CAN base_convert() be changed to return an actual number instead of a string if tobase=10? Seems a waste to convert a base 10 result to string like now... :-? Thanks! Matt ----- Original Message ----- From: "Matt W" Sent: Friday, July 28, 2006 > Hi, > > More thoughts... > > I forgot to say last time that the manual doesn't mention the dec*() > parameter being treated as unsigned. The *printf() specifiers b/o/x/X > already do this (although the manual doesn't say that either, only for %u). > > After looking through the comments for dechex(), there's another thing: 32- > vs 64-bit. On a 64-bit system, I think dechex(-123) would currently return > ffffffffffffff85, which when reversed on my system gives > > php -d precision=20 -r "var_dump(hexdec('ffffffffffffff85'));" > float(18446744073709552000) > > Are you saying, Michael, that the negative behavior should be left as-is for > people to see "how the number is stored by the computer?" I think just > using the *printf() specifiers would better. IMO, the dec*() and *dec() > functions should work the same as the corresponding to/from base with > base_convert() (absolute value), and vice-versa. > > BTW, can base_convert() simply return an actual number instead of a string > when tobase=10? Again, to be the same as *dec() and avoid conversion to > string if it's just going to be used in numeric context. > > > Matt