Skip to content

round 123456789012.1245 failed with precision 2 #14451

Closed
@AnatoliyDanchuk

Description

@AnatoliyDanchuk

Description

The following code:

<?php
echo round(123456789012.1245, 2);

Resulted in this output:

123456789012.13

But I expected this output instead:

123456789012.12

It reproduced on different OS, different php versions after 5.3.0 (included).
Example in online sandbox:
https://onlinephp.io?s=s7EvyCjg5eLlSk3OyFcoyi_NS9EwNDI2MTUzt7A0MDTSMzQyMdVRMNK0BgA%2C&v=8.3.7

PHP Version

8.3.7

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