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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: francis dot crossen at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sat Dec 21 14:01:32 2024 UTC