Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105043 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 16107 invoked from network); 3 Apr 2019 15:38:17 -0000 Received: from unknown (HELO mail-it1-f194.google.com) (209.85.166.194) by pb1.pair.com with SMTP; 3 Apr 2019 15:38:17 -0000 Received: by mail-it1-f194.google.com with SMTP id k64so10878195itb.5 for ; Wed, 03 Apr 2019 05:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CjOYZnR0YgiYGEET2zOV1LubryMTsITF9RHJpNAhXq4=; b=jemjYnlfJF+bYlKpItI/XMY5DqIBYermyZqg/78O3dFPc63pvVPvAkz1QH6wFRRxBq lRu7fXr45C3gAcNUP1tpRoTbRz0Tt8hE3U+jUMrDSjqwfwZe1Y70xvleSE9G2gn8gUMF Pk6peESqk1NLDL2FSL7Qg0HGsvY2AJZANPiioTF0AUTH5Jd5cfgBleiOLjUKqDaEpn9N zqV3AlHXCsbEPydH4zDvtTsxYMhvCg+HSQ9d4u8F2zzrOacPaRUs+RSD5tsk97RUSb30 n7TIFsq6GLh1UyQp313g0dAhB2vaZ5nRG962rRhIjUKI/4MrprBoHAGByGcA1VCN+5O2 xNVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CjOYZnR0YgiYGEET2zOV1LubryMTsITF9RHJpNAhXq4=; b=Om2OnmMynv/c4K76bH7RKIXlXP3ojwf/anIzFrc8pOWPh0+EEZjKYYSiZva+Fu0nef d8l7RmI1QPuOOCsiJ53nsWUfRyuqkLiYNNIJ6woQHmohwgQFWRFq0XkG0s29qw8tnKBA nKSS4MBx9RZktOz7eTd+9/D3X6uJXTLMAdOHtvsUGQ/Zn2DPEFnr4QrJw8km3fCGFjZs Rsi3vumeNoKHOt84YwFwHgl7TpBzmiS/vGrPgqzj9nIAvqdXfWw88uJ8JoiswUFpz4GV MafWpBNCvlFua8XcAXbGZ7/yML7ttZNk9TFKcOV9/hbxFv13dEEF9ptOxduQDGBzViYh icAQ== X-Gm-Message-State: APjAAAXr21qO9pRUGhTfhe025wrvnyitz4HskfPgtEyFMD94SztY9Cw/ 421hkl8z1EVKPhmboOuVgSg3wV2JFUyMutxdK0g= X-Google-Smtp-Source: APXvYqx+99BbNidkNd/Xj5WlXHZfu58aaHp0I4K5wSea7S/q2Okr3EfHyOpCVhyUV+y8RSJBI4W7Bls06UiYk59rBXs= X-Received: by 2002:a24:dc41:: with SMTP id q62mr55417itg.94.1554294820159; Wed, 03 Apr 2019 05:33:40 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 3 Apr 2019 14:33:27 +0200 Message-ID: To: Michael Wallner , krakjoe@gmail.com, dafneves@gmail.com Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000a1c58405859f7615" Subject: Re: [PHP-DEV] PHP_FLOAT_MIN is positive From: benjamin.morel@gmail.com (Benjamin Morel) --000000000000a1c58405859f7615 Content-Type: text/plain; charset="UTF-8" > > It really don't make much sense: > var_dump( PHP_FLOAT_MIN < 0 ); > var_dump( PHP_INT_MIN < 0 ); I quite agree that this is an inconsistency, but I guess that it's here to stay now for BC reasons. What we can do is fix the doc. > 2.2250738585072E-308 > This is negative. It isn't, it is a strictly positive number with a negative exponent: 0.000(...)00022250738585072. FLT_MIN is the smallest real near 0. Are you looking for -FLT_MAX? > With IEEE754 floats, there are positive and negative zeros, so the range > above and below 0 is the same. It's interesting to know that - PHP_FLOAT_MAX is actually the smallest representable floating point number (unlike - PHP_INT_MAX). It would be great to document this as well. I would propose to change the current documentation to: PHP_FLOAT_MIN (float) > Smallest representable POSITIVE floating point number. If you need the > smallest representable floating point number, use - PHP_FLOAT_MAX. > Available as of PHP 7.2.0. What we could also do is introduce another constant to represent the actual smallest possible float, but its naming would likely conflict with PHP_FLOAT_MIN, and it does not bring much value, so I'm not sure whether this is a good idea. We did introduce a PHP_INT_MIN though, even though it was available as ~ PHP_INT_MAX, so it's worth mentioning. Thoughts? On Wed, 3 Apr 2019 at 13:50, Michael Wallner wrote: > On 03/04/2019 12:27, Diogo Neves wrote: > > It really don't make much sense: > > > > > > > var_dump( PHP_FLOAT_MIN < 0 ); > > var_dump( PHP_INT_MIN < 0 ); > > > > On Wed, Apr 3, 2019 at 10:52 AM Benjamin Morel > > > wrote: > > > >> Hi internals, > >> > >> I just used PHP_FLOAT_MIN for the first time, and was surprised that it > is > >> the smallest **positive** number representable. Is this expected? > >> > >> This is unlike PHP_INT_MIN, which is the absolute smallest representable > >> integer, and as such is negative: > >> > >> echo PHP_INT_MIN; // -9223372036854775808 > >> echo PHP_FLOAT_MIN; // 2.2250738585072E-308 > >> > >> If it is intended, maybe the doc > >> should be clear > >> about this, at the moment it is just: > >> > >> Smallest representable floating point number. > >> > >> > >> Which is confusing IMO. > > FLT_MIN is the smallest real near 0. Are you looking for -FLT_MAX? > With IEEE754 floats, there are positive and negative zeros, so the range > above and below 0 is the same. > > > -- > Regards, > Mike > > --000000000000a1c58405859f7615--