Skip to content

ext/bcmath - Number::round() removes trailing 0s unnecessarily #17061

Closed
@SakiTakamachi

Description

@SakiTakamachi

Description

The following code:

<?php

var_dump(
    bcround('0.500', 5),
    bcround('0.995', 2),
    (string) new BcMath\Number('0.500')->round(5),
    (string) new BcMath\Number('0.995')->round(2),
);

Resulted in this output:

string(7) "0.50000"
string(4) "1.00"
string(3) "0.5"
string(1) "1"

But I expected this output instead:

string(7) "0.50000"
string(4) "1.00"
string(7) "0.50000"
string(4) "1.00"

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