feat: Add PHP 8.4 bcfloor(), bcceil(), and bcround() functions#6
Merged
Conversation
- 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]>
Owner
Author
|
@claude PHPUnit がエラーになるようですので修正をお願いします |
|
Claude finished @nanasess's task —— View job Fixed! ✅Todo List
Issue SummaryThe 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. SolutionFixed 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]>
Closed
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3
Summary
Implements the three new bcmath functions added in PHP 8.4:
bcfloor()- Rounds down to the nearest integerbcceil()- Rounds up to the nearest integerbcround()- Rounds to a given decimal place with support for different rounding modesAll functions include comprehensive unit tests and follow the project's coding standards.
Generated with Claude Code