Skip to content

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

Closed
@SakiTakamachi

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions