Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61875 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56028 invoked from network); 30 Jul 2012 13:52:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jul 2012 13:52:54 -0000 Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:39082] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 52/45-16347-5B196105 for ; Mon, 30 Jul 2012 09:52:53 -0400 Received: by vbbfs19 with SMTP id fs19so5235291vbb.29 for ; Mon, 30 Jul 2012 06:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=7q6YORolTG+NqnmsdpMxEAWNNNiCFVaWjMU5aUM4PMw=; b=dEar35L+iVPlMwtj+DEP6LMDo8uw7tX3TA0+8befisaPht910QEGh1ZmodzmqNuUHs THpP7xl4KRKMVnJVO028eBRJFQikj20uYEqERwLYaNYisDlVVuOH9RbfL6yUyYzSr8ih snEEXcQs1kb63S77iTEviBScYCiWKgDE/drO4+qur5ceN4Y7ifyD6cA9EX5YfGPYEQJY xZ17ORP6fuNra4iPK363kCoxbuLfj1QEyg8PB8Aawi4LL1yg8o3WBlXwombCCji/6wj6 BIAvTIKMcO/S7+lvd7sAT1foMjhz/LEZ3Bk1F3uB4F0U+Z6g7V7DVSmmMY9lC0gd+UnJ 0Qww== Received: by 10.52.98.8 with SMTP id ee8mr9696994vdb.58.1343656370736; Mon, 30 Jul 2012 06:52:50 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.220.195.3 with HTTP; Mon, 30 Jul 2012 06:52:29 -0700 (PDT) In-Reply-To: References: Date: Mon, 30 Jul 2012 21:52:29 +0800 X-Google-Sender-Auth: GZzXT4dRN2X7ajf7KB2dyXzUKmY Message-ID: To: Devis Lucato Cc: PHP Developers Mailing List Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] bug on bc math? From: laruence@php.net (Laruence) Hi: I'd like mark this as a doc problem, see the comment of the bcmatch lib: /* The multiply routine. N2 times N1 is put int PROD with the scale of the result being MIN(N2 scale+N1 scale, MAX (SCALE, N2 scale, N1 scale)). */ void bc_multiply (bc_num n1, bc_num n2, bc_num *prod, int scale TSRMLS_DC) and * Here is the full add routine that takes care of negative numbers. N1 is added to N2 and the result placed into RESULT. SCALE_MIN is the minimum scale for the result. */ void bc_add (n1, n2, result, scale_min) thanks On Mon, Jul 30, 2012 at 8:47 PM, Devis Lucato wrote: > Hi, > > before raising a bug I was wondering if anyone noticed this odd behavior in > BC math functions ? > > Actual > > php -r "echo bcmul('1.1', '9.0', 5);" ==> 9.90 > php -r "bcscale(5); echo bcmul('1.1', '9.0');" ==> 9.90 > php -r "bcscale(5); echo bcadd('8.9', '1.0');" ==> 9.90000 > > > Expected > > php -r "echo bcmul('1.1', '9.0', 5);" ==> 9.90000 > php -r "bcscale(5); echo bcmul('1.1', '9.0');" ==> 9.90000 > php -r "bcscale(5); echo bcadd('8.9', '1.0');" ==> 9.90000 > > > Seen on 5.3 and 5.4. > > Looking at > http://git.php.net/?p=php-src.git;a=history;f=ext/bcmath/bcmath.c;h=5dfafa8bd8dbc1703af2ea4452ac2b05b765a619;hb=HEADI > couldn't see any recent change related to this bug. > > Thank you -- Laruence Xinchen Hui http://www.laruence.com/