php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8961 Omited Math Function
Submitted: 2001-01-27 20:46 UTC Modified: 2001-09-09 15:56 UTC
From: Frank at kujawski dot Org Assigned:
Status: Not a bug Package: Math related
PHP Version: 4.0 Latest CVS (27/01/2001) OS: N/A
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: Frank at kujawski dot Org
New email:
PHP Version: OS:

 

 [2001-01-27 20:46 UTC] Frank at kujawski dot Org
There are a set of four math function that convert real numbers to integers, trunc is missing.  Other functions of use are Frac, Mod, Div.

Round: return closest integer to argument, if fractional is .5 then return closest even integer.

Ceiling: return smallest integer greater than or equal to argument

Floor: return largest integer less than or equal to argument

Trunc: if argument is positive, return floor of argument, otherwise return ceiling of argument.

Frac: return abs(argument - trunc(argument))

Mod: returns remainder of the division of two arguments

Div: returns quotiant of the division of two arguments


(I ran into this problem when converting a decimal number to an IP number.)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-27 20:55 UTC] rasmus@php.net
Not sure what you are asking for here.
round() exists
Modulus exists with the modulus operator.  ie. echo 3%2;
ceil() exists
floor() exists
Division obviously exists
Trunc sort of exists: echo (int)10.57;
Frac can be derived as well.  But I suppose that is the one you are asking for a native function for?
 [2001-09-09 05:31 UTC] sterling@php.net
PHP is not to my knowledge ASP.  This is won't (shouldn't)
be added anytime soon...
 [2001-09-09 15:56 UTC] Frank at kujawski dot Org
I am not sure where ASP, came from.
These are all native functions of most Numeric Processors.
My suggestion was just that, a suggestion.
It allows for completionof functions that I thought would be easy to implemented.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 02 20:01:32 2024 UTC