Skip to content

ext/bcmath - bcround() results may be incorrect #17064

Closed

Description

@SakiTakamachi

Description

The following code:

<?php

var_dump(
    round(0.01, -1, RoundingMode::AwayFromZero),
    round(0.01, -2, RoundingMode::AwayFromZero),
    bcround('0.01', -1, RoundingMode::AwayFromZero),
    bcround('0.01', -2, RoundingMode::AwayFromZero),
);

Resulted in this output:

float(10)
float(100)
string(2) "10"
string(1) "0" // this is wrong

But I expected this output instead:

float(10)
float(100)
string(2) "10"
string(3) "100"

PHP Version

PHP 8.4 >=

Operating System

No response

Activity

  1. self-assigned this
    on Dec 6, 2024
  2. added a commit that references this issue on Dec 16, 2024
    52ebdfb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions