php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78187 Exponentiation operator gives incorrect result
Submitted: 2019-06-20 08:40 UTC Modified: 2019-06-20 08:45 UTC
From: francis dot crossen at gmail dot com Assigned:
Status: Not a bug Package: *Math Functions
PHP Version: 7.3.6 OS: n/a
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
19 + 30 = ?
Subscribe to this entry?

 
 [2019-06-20 08:40 UTC] francis dot crossen at gmail dot com
Description:
------------
Tested in PHP shell on Linux and Windows

Test script:
---------------
<?php

// expect 1
echo -1 * -1 . PHP_EOL;
echo pow(-1, 2) . PHP_EOL;
echo -1 ** 2 . PHP_EOL;

// expect 49
echo -7 * -7 . PHP_EOL;
echo pow(-7, 2) . PHP_EOL;
echo -7 ** 2 . PHP_EOL;




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-20 08:45 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2019-06-20 08:45 UTC] nikic@php.net
-1 ** 2 is -(1**2).

I would recommend to avoid spaces around ** to indicate that this is a high-precedence operator.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 07:01:28 2024 UTC