PHP Classes

X base: Convert numbers between different numeric bases

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 279 All time: 7,575 This week: 196Up
Version License PHP version Categories
x-base 1.0GNU General Publi...5PHP 5, Math
Description Author

This class can be used to convert numbers between different numeric bases.

It can take a number represented in a numeric base and convert it to the representation in a different base.

Currently it supports numeric bases between 2 and 72.

Picture of Uwe Stein
Name: Uwe Stein <contact>
Classes: 5 packages by
Country: Germany Germany
Age: 62
All time rank: 37323 in Germany Germany
Week rank: 587 Down32 in Germany Germany Down

Details
coded by uwe stein Copyright (C) 2010 Uwe Stein hints, suggestions and bug reports are welcome. Here is a small overview how to use the x_base object ---------------------------------------------------------------Class mebers:--------------------------------------------------- alnum_digit = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" default use upper case letters num the umber encoded with base base the used base ( bin, dec,..., oct, ... hex, ... ) max_base the maximum base = strlen( $this->alnum_digit ); dec_num this always keeps the decimal Value of num ----------------------------------------------------------- public functions -------------------------------------------------- public function __construct($num,$base=10) param : $num = the number ( endoded with base ), [$base] the used base public function getNum() param : none return : the the encoded value public function getDec() param : none return : the decimal value of num public function getBase() param : none return : the used base public function getMaxBase() param : none return : the highest valid value for base public function toUpper() param : none return : none purpose: changes the digit-set to upper Letters public function toLower() param : none return : none purpose: changes the digit-set to upper Letters public function mixedDigits() param : none return : none purpose: changes the digit-set to upper and lower Letters note : "01234567890123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" with mixed set the "A" and "a" represent different values public function getConvNum($base) param : the base to encode the number return : string with the encoded number purpose: retrieve a number encoded with bas note : the func doesnt change(restores) the values of class members public function setNum($value,$base=10) param : $num = the number ( endoded with base ), [$base] the used base return : none purpose: change the values of an existing object public function setBase($base) param : the new base return : none purpose: change the used base ( and rebuild the encoded number )
Screenshots  
  • x_base_screenshot
  Files folder image Files  
File Role Description
Accessible without login Plain text file readme.txt Doc. small documentation
Accessible without login Plain text file test_x_base.php Example some examples
Plain text file x_base.php Class the objekt-class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:279
This week:0
All time:7,575
This week:196Up