Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71008 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92035 invoked from network); 5 Jan 2014 17:24:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jan 2014 17:24:00 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.220.46 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.220.46 mail-pa0-f46.google.com Received: from [209.85.220.46] ([209.85.220.46:34484] helo=mail-pa0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/C0-19934-E2599C25 for ; Sun, 05 Jan 2014 12:23:59 -0500 Received: by mail-pa0-f46.google.com with SMTP id kp14so15688012pab.19 for ; Sun, 05 Jan 2014 09:23:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=9JihuELcfz3EUXB7kwS7AkoQpaUzHY3NHXj64Pv4QKY=; b=Ieftb87fnzrYU1vuM2SgCh6L/Thxw9qeiSYrvdVVqVq1+mPSaQVW+YBSg0LpCcty9T g8yIV5GsxamxH6ThY9AGzZD6BuTgyemGU7sRO8VJitHTZG3ZOMthDHknz23IA8d4V82m DoHU5l35A2dXFxY+g1eqWlAwdCV186PuVInPgd/6lfLwvJnPOyymCYUnzUaHbggCq+Wz /zkXQzIeUyaxn+4HuGzMdt61P1Vt7cYnYrYSTWShL4CgrJZ0GHHgbeap5gylfhJkUppI q2VHa/GjXX54y1j5qLyimYUopfhB3B0+cE2To8BdzZmUdwHAaqVCQqJBYZdnUHcGxKYF LUAg== X-Gm-Message-State: ALoCoQlfprLE300KRgHcwdwbefSjZsH5HMLDKpLY03USmQ7NImHpfQ7LljkkZ211cZHThCkKzAq3 MIME-Version: 1.0 X-Received: by 10.69.31.170 with SMTP id kn10mr115761377pbd.106.1388942635034; Sun, 05 Jan 2014 09:23:55 -0800 (PST) Sender: php@golemon.com Received: by 10.70.77.164 with HTTP; Sun, 5 Jan 2014 09:23:54 -0800 (PST) X-Originating-IP: [173.252.71.189] In-Reply-To: <52C90D9F.6080802@sugarcrm.com> References: <52C90D9F.6080802@sugarcrm.com> Date: Sun, 5 Jan 2014 09:23:54 -0800 X-Google-Sender-Auth: LCXhgqgIttABQzs4afNOfwLHgrA Message-ID: To: Stas Malyshev Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [RFC] Floating Point support in GMP extension From: pollita@php.net (Sara Golemon) On Sat, Jan 4, 2014 at 11:45 PM, Stas Malyshev wrote: > I have a question here: why we must keep gmp integers and gmp floats > within the same object? They have different types in GMP library, PHP > has different types for ints and floats, internally in PHP they would be > using different code and different structures, API would be different - > why have the same object at all? > I considered that approach too (and even had it in my initial draft as "proposal#2"), but what I ended up putting into the RFC felt more "PHP" to me (in that we're dealing with a number, not an int versus a float necessarily). I'm totes not averse to having GMPInt and GMPFloat (descended from abstract GMPNumber); After all, that's what the discussion period is for. > Also, I'm not sure how exactly "all other gmp_*() functions" are > supposed to work on floats - for many of them it just make no sense > (such as factorial or q/r division or modulo), for others like bit > functions it technically could make sense but would probably be not > useful since nobody does bit ops on floats... Maybe it would make more > sense to look into what GMP library does with floats and write different > function set from there? > On a case by case basis. As you say, some of those cases will be "throw an error on trying to use a float", and some functions would be new. For common stuff though, like gmp_add(), I think it'd be silly to have gmp_add() + gmp_float_add() as separate APIs, especially since one would have to be smart enough to handle Int+Float mixing anyway. ((Or you'd have to perform explicit casts, e.g.: $three = gmp_add( gmp_init("1") + gmp_int(gmp_float_init("2.0")) ); -Sara