WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Library of math functions to expand the functionality of PHP3. Version 1.2.1 fixes a major problem with the gcd function.
Categories : Algorithms, PHP, Math. Update Picture
Nick Bastin
Date : Jan 17th 1999
Grade : 2 of 5 (graded 4 times)
Viewed : 7247
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Nick Bastin
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php

/*
** mathlib v1.2.1 04/25/98 nbastin
**
** MathLib for PHP3 maintained by Nick Bastin <nbastin@rbbsystems.com>
** If you have source for functions that you would like to see added, or
** have functions that you would like to see added but don't know how to
** write yourself, please email me.
**
** All functions tested before distribution for functionality, and a
** reasonable bit of accuracy. However, these functions have
** not undergone extensive testing for their precision and accuracy, and
** you use at your own risk.
**
** That said, quite a few errors did turn up in testing, and I think I
** got them all. However, if you find an error, please let me know.
**
** To use these functions, include them in your PHP scripts
**
** - Nick Bastin <nbastin@rbbsystems.com>
*/

/*
** There's already a 'round' function in PHP...do we need this?
** Author: Bjorn Borud, Guardian Networks AS, <borud@guardian.no>
*/
function roundoff($v) {
if ( $v - floor($v) >= 0.5) {
return(ceil($v));
} else {
return(floor($v));
}
}

/*
** Converts degrees to radians
** Author: Bjorn Borud, Guardian Networks AS, <borud@guardian.no>
** Modified to break reliance on PI variable by Nick Bastin, <nbastin@rbbsystems.com>
*/
function deg2rad($degrees) {
return ((pi(void) * $degrees) / doubleval(180));
}

/*
** Converts radians to degrees
** Author: Nick Bastin, RBB Systems, <nbastin@rbbsystems.com>
*/
function rad2deg($radians) {
return (($radians * doubleval(180)) / pi(void));
}

/*
** Base-$base logarithm of $val. Useful for those evaluating logarithms in non-
standard bases
** Author: Nick Bastin, RBB Systems, <nbastin@rbbsystems.com>
*/
function baselog($base,$val) {
return ((log10($val))/(log10($base)));
}

/*
** Factorial function (Be careful, this number can grow out of control very quickly)
** Since you can't perform a factorial of a non-integer, the function casts $number
to an integer.
** Author: Nick Bastin, RBB Systems, <nbastin@rbbsystems.com>
*/
function factorial($number) {
$a = $b = (int) $number;
while ($b>1) {
--$b;
$a = $a * $b;
}
return $a;
}

/*
** Greatest Common Divisor function - Returns the greatest common divisor of $x and
$y
** Author: Nick Bastin, RBB Systems, <nbastin@rbbsystems.com>
*/
function gcd($x,$y) {
$x = abs($x);
$y = abs($y);
if ( $x + $y = 0 ) {
return "ERROR";
} else {
while ($x > 0) {
$z = $x;
$x = $y % $x;
$y = $z;
}
return $z;
}
}

/*
** Functions coming soon:
**
** - Infinitely precise division function
** - Factoring function
** - Prime number evaluation
** - Prime number generator
*/

?>



Prime number finder (Sieve of Erastothenes)
Categories : PHP, Algorithms, Math.
Diffusion-Limited Aggregation visualization
Categories : PHP, Graphics, Algorithms, Math.
Reverse a given number
Categories : PHP, Beginner Guides, Algorithms, Math.
Show the steps for converting a number from a given base to base 10. Shows the steps involved in converting a number from a given base to base 10.
Categories : PHP, Math., Algorithms
How to judge if an integer is odd or is even in Php3?
Categories : Math., PHP, Algorithms
A very simple and efficient split bar the B-Z bar , for mysql and php ... Tired of obfuscated code try this one ...
Categories : PHP, Databases, MySQL, Algorithms
Credit Card Identification and Validation Class - The credit_card class provides methods for cleaning, validating and identifying the type of credit card numbers.
Categories : PHP, PHP Classes, Credit Cards, Ecommerce, Algorithms
Prime Spiral is a image plotted with all the primes in a number spiral.
Categories : Algorithms, Graphics, GD image library, Math.
Dollar Serial Number Validator
Categories : PHP, Security, Algorithms
Boolean Keyword Interpreter
Categories : PHP, Algorithms, Search Engines
IPhider Obscure Any URL Anonymity connection lores obfuscation corporate survival.
Categories : PHP, Algorithms, Security, URLs
How to Generate a random 8 character string in php3?
Categories : PHP, Algorithms
Latitude-Longitude to Miles
Categories : PHP, Utilities, Math.
Browse a MySQL database & draw a tree view & load final items into a template page.
Categories : MySQL, Complete Programs, Algorithms, PHP, Databases
Recursive function to move files on a filesystem. It can be minor changed in order to copy recursively.
Categories : PHP, Filesystem, Algorithms