Skip to content

base_convert outputs at most 64 characters #22395

Description

@Sjord

Description

The following code:

<?php
var_dump(base_convert("1111111111111111111111111111111111111111111111111111111111111", 36, 16));

Resulted in this output:

string(64) "0000000000000000000000000000000000000000000000000000000000000000"

But I expected this output instead:

string(78) "4b61b5e0639ff90000000000000000000000000000000000000000000000000000000000000000"

This is likely a regression due to Rework some string-to-number and vice-versa functions to work smarter · php/php-src@f45555e from 2001.

Relevant code is _php_math_zvaltobase in ext/standard/math.c.

PHP Version

PHP 8.5.4 (cli) (built: May 25 2026 12:19:37) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.5.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.4, Copyright (c), by Zend Technologies

Operating System

Linux php 7.0.0-22-generic #22-Ubuntu SMP PREEMPT_DYNAMIC Mon May 25 15:37:49 UTC 2026 aarch64 GNU/Linux

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions