8000 ext/bcmath - `Number::round()` removes trailing 0s unnecessarily · Issue #17061 · php/php-src · GitHub
[go: up one dir, main page]

Skip to content
ext/bcmath - Number::round() removes trailing 0s unnecessarily #17061
Closed
< 8583 svg focusable="false" aria-label="Issue" class="octicon octicon-issue-closed Octicon-sc-9kayk9-0 hTWZgt" role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom">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

    0