php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25087 "%" operate
Submitted: 2003-08-13 22:48 UTC Modified: 2003-08-15 07:14 UTC
From: flyruns at hotmail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.2 OS: windows 2000 advanced server
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: flyruns at hotmail dot com
New email:
PHP Version: OS:

 

 [2003-08-13 22:48 UTC] flyruns at hotmail dot com
Description:
------------
When i use '%' operate when i account can't get my hope;

Reproduce code:
---------------
<?php
 echo  27%13;//  =1

 echo  27%13.5;// =1 (behove is 0)

 echo  27%13.9;// =1 (behove is 13.1)
?>

Expected result:
----------------
account right;


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-13 22:50 UTC] sniper@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

..

 [2003-08-13 22:57 UTC] flyruns at hotmail dot com
Thanks i find it in c is right~ sorry~
 [2003-08-15 07:14 UTC] sniper@php.net
(Restored this comment due to database got corrupted..)

For the record (for anyone who looks up this "bug" in the future):

% (The modulous operator) is an integer operator.

Using an integer operator with float values will simply get those float values truncated to integers.

Ergo:   27 % 13.5 gets turned into 27 % 13, hence the result value of 1
is correct.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC