Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: Add PHP 8.4 bcfloor(), bcceil(), and bcround() functions#6

Merged
nanasess merged 2 commits into
mainfrom
claude/issue-3-20250610_075034
Jun 11, 2025
Merged

feat: Add PHP 8.4 bcfloor(), bcceil(), and bcround() functions#6
nanasess merged 2 commits into
mainfrom
claude/issue-3-20250610_075034

Conversation

@nanasess
Copy link
Copy Markdown
Owner

Closes #3

Summary

Implements the three new bcmath functions added in PHP 8.4:

  • bcfloor() - Rounds down to the nearest integer
  • bcceil() - Rounds up to the nearest integer
  • bcround() - Rounds to a given decimal place with support for different rounding modes

All functions include comprehensive unit tests and follow the project's coding standards.

Generated with Claude Code

- Implemented bcfloor() to round down to the nearest integer
- Implemented bcceil() to round up to the nearest integer  
- Implemented bcround() to round to a given decimal place with support for different rounding modes
- Added comprehensive unit tests for all three functions
- Functions support both positive and negative numbers, various scales, and handle edge cases
- bcround() supports negative scales and all PHP rounding modes (HALF_UP, HALF_DOWN, HALF_EVEN, HALF_ODD)

Based on the implementation reference from https://stackoverflow.com/a/1653826

Co-authored-by: nanasess <[email protected]>
@nanasess
Copy link
Copy Markdown
Owner Author

@claude PHPUnit がエラーになるようですので修正をお願いします

@claude
Copy link
Copy Markdown

claude Bot commented Jun 10, 2025

Claude finished @nanasess's task —— View job


Fixed! ✅

Todo List

  • Install dependencies with composer
  • Run PHPUnit to identify the errors
  • Read the implementation files to understand the issue
  • Fix the failing tests or implementation
  • Verify all tests pass
  • Run code style checks
  • Commit and push the fixes

Issue Summary

The bcfloor(), bcceil(), and bcround() functions were returning values with decimal places because a previous test (test_argumentsScaleCallstatic) was setting the global bcscale to 4 and not resetting it. This affected all subsequent tests that didn't explicitly set a scale parameter.

Solution

Fixed by saving and restoring the original scale value in the test_argumentsScaleCallstatic function. This ensures the test doesn't pollute the global state for subsequent tests.

All PHPUnit tests now pass successfully! 🎉

…t pollution

The test_argumentsScaleCallstatic was setting bcscale to 4 and not resetting it,
which caused subsequent tests (bcfloor, bcceil, bcround) to fail because they
were picking up the global scale value when no explicit scale was provided.

Co-authored-by: nanasess <[email protected]>
@nanasess nanasess marked this pull request as ready for review June 11, 2025 05:15
@nanasess nanasess merged commit 3f86639 into main Jun 11, 2025
18 checks passed
@nanasess nanasess mentioned this pull request Jun 11, 2025
claude Bot added a commit that referenced this pull request Jun 11, 2025
- Changed package name to bcmath-polyfill
- Added modern, stylish formatting with centered header and emoji icons
- Included PHP 8.4 bcmath functions (bcfloor, bcceil, bcround) from PR #6
- Added credit to original phpseclib/bcmath_compat repository
- Updated badges and links to match new repository
- Added comprehensive usage examples and feature list

Co-authored-by: nanasess <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP8.4 で追加された bcfloor(), bcceil(), bcround() の追加

1 participant