brick / math

Arbitrary-precision arithmetic library for PHP
MIT License
1.78k stars 75 forks source link

Accept hexadecimal input #64

Open 99hops opened 2 years ago

99hops commented 2 years ago

Is it possible to add support for hexadecimal input to avoid additional conversion?

Example: BigDecimal::of('0x5208')->multipliedBy('0x59682f08');

BenMorel commented 2 years ago

Hi,

I'm not sure if it makes sense to add more convenience formats in of(): it already accepts multiple formats to cover the needs of the 3 number classes (BigInteger, BigDecimal, BigRational), and accepting hexadecimal is opening the Pandora box: should we accept 0b afterwards?

Is it really a big issue to call BigInteger::fromBase()?