krowinski/bcmath-extended 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

krowinski/bcmath-extended

最新稳定版本:8.0.0

Composer 安装命令:

composer require krowinski/bcmath-extended

包简介

Extends php BCMath lib for missing functions like floor, ceil, round, abs, min, max, rand for big numbers. Also wraps existing BCMath functions. (more http://php.net/manual/en/book.bc.php) Supports scientific notations

README 文档

README

PHP Tests Code Coverage Latest Stable Version Total Downloads License

Extends php BCMath lib for missing functions like abs, min, max, rand, fact, log for big numbers. Handles scientific notation like 1.0E+35 to be used with BCMath. Also wraps existing BCMath functions. (more http://php.net/manual/en/book.bc.php)

Installation

composer require krowinski/bcmath-extended

Features

  • config
    • setTrimTrailingZeroes - disable|enable trailing zeros (default trimming is enabled)
  • new tool methods
    • convertToNumber - converts scientific notation, string and int to BcMath\Number
      • getScale - gets current global scale
      • getDecimalsLengthFromNumber - gets amount of decimals
      • hexdec - converting from hexadecimal to decimal
      • dechex - converting from decimal to hexadecimal
      • bin2dec - converting from binary to decimal
      • dec2bin - converting from decimal to binary
  • new math functions
    • round
    • abs
    • rand
    • max
    • min
    • roundDown
    • roundUp
    • roundHalfEven
    • ceil
    • exp
    • log
    • fact
    • pow (supports fractional)
    • mod (supports fractional + scale)
      • bitwise operators
        • bitXor
        • bitOr
        • bitAnd
  • proxy for original functions
  • all functions supports scientific notation
  • all functions are static, so it can be easily replaced by this lib

Info

As of 7.2 float can be passed to bcmod, but they don't return correct values (IMO)

I created bug for this in https://bugs.php.net/bug.php?id=76287, but it was commented as documentation issue not a bug.

bcmod() doesn't use floor() but rather truncates towards zero,
which is also defined this way for POSIX fmod(), so that the
result always has the same sign as the dividend.  Therefore, this
is not a bug, but rather a documentation issue.

But I still will use floor not truncated for mod in this lib.

统计信息

  • 总下载量: 973.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 78
  • 点击次数: 1
  • 依赖项目数: 17
  • 推荐数: 0

GitHub 信息

  • Stars: 77
  • Watchers: 5
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04