PHP code example of cse / helpers-math-converter
1. Go to this page and download the library: Download cse/helpers-math-converter library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cse / helpers-math-converter example snippets
$mb = MathConverter::toMb('300K');
$sub = bcsub(
MathConverter::roundDecimal($mb, 4), // 0.293
MathConverter::cutDecimal($mb, 4), // 0.2929
4
);
// 0.0001
MathConverter::binToHex($sub);
// 302e30303031
MathConverter::hexToBin('48454c4c4f');
// HELLO
MathConverter::binToHex('HELLO');
// 48454c4c4f
MathConverter::mbToBytes(1);
// 1048576
MathConverter::bytesToMb(1048576);
// 1
MathConverter::bytesToMb(1000000, 4);
// 0.9537
MathConverter::gbToBytes(1);
// 1073741824
MathConverter::bytesToGb(1073741824);
// 1
MathConverter::bytesToGb(1000000000, 4);
// 0.9313
MathConverter::gbToMb(1);
// 1024
MathConverter::mbToGb(1024);
// 1
MathConverter::mbToGb(1000, 4);
// 0.9766
MathConverter::toMb('1M');
// 1
MathConverter::toMb('0.001P');
// 1073741.824
MathConverter::toMb('0.1T');
// 104857.6.824
MathConverter::toMb('1G');
// 1024
MathConverter::toMb('1000K');
// 0.9765625
MathConverter::toMb('1000000B');
// 0.95367431640625
MathConverter::cutDecimal(11.726);
// 11.72
MathConverter::cutDecimal('-67.099', 1);
// -67
MathConverter::roundDecimal(11.726);
// 11.73
MathConverter::roundDecimal('-67.099', 0);
// -67
bash
phpunit PATH/TO/PROJECT/tests/
bash
phpunit --configuration PATH/TO/PROJECT/phpunit.xml