Download the PHP package tetthys/bc without Composer

On this page you can find all versions of the php package tetthys/bc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bc

System Requirements

Bc

Bc is a small and simple but accurate tool for calculation. It uses bcmath functions internally.

You can get the exact result you want.

There are no rounding issues if you have enough memory.

It's like calculating to N decimal places using a pen and paper with your hands.

Why Bc?

Do you think below test will pass?

Unfortunately, 0.1 + 0.2 is not 0.3 in php

It fails for the following reason:

Failed asserting that 0.30000000000000004 is identical to 0.3.

That's why I made this.

Usage Examples

Calculation

After giving a scale value, you can calculate in order.

It also can be used like below:

Comparison

After giving a scale value, you can compare.

It also can be used like below:

About num method

It specifies a number at which the calculation begins. It always returns Bc instance.

Or you can use the below instead:

About scale method

It specifies a scale value to be passed on to a next operation. The default value is 0.

It supports chaining:

Supported Calculation Methods

Calculation methods expect string or Bc instance. And they always return Bc instance.

add

It adds a number

sub

It subtracts a number

mul

It multiplies a number

div

It divides a number

mod

It calculates the modulus of a number

pow

It calculates the power of a number

powmod

It calculates the power of a number with modulus

sqrt

It calculates the square root of a number

Supported Comparison Methods

Comparison methods expect string or Bc instance. And they always return bool.

isGreaterThan

It checks if a number is greater than another number

isGreaterThanOrEqual

It checks if a number is greater than or equal to another number

isLessThan

It checks if a number is less than another number

isLessThanOrEqual

It checks if a number is less than or equal to another number

isEqual

It checks if a number is equal to another number

isDifferent

It checks if a number is different from another number

gt

Same as isGreaterThan

gte

Same as isGreaterThanOrEqual

lt

Same as isLessThan

lte

Same as isLessThanOrEqual

is

Same as isEqual

isNot

Same as isDifferent

Runtime Exceptions

ScaleCannotBeUsedForOperation

This is thrown when scale is less than 0.

ValueCannotBeUsedForOperation

This is thrown when value is not a number.

How to contribute and test in same environment?

docker-compose up

attach shell to phptestenv container

install dependencies with composer

run test

Or, you can run test from host OS using

What I want to say

It is currently June 2024.

I'm still learning commit and branch naming conventions and php composer rules.

I hope you understand even if some of the names are bad.

Thank you.


All versions of bc with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tetthys/bc contains the following files

Loading the files please wait ....