Repository navigation
Number.toString returns its string, and converts in any radix - #56
Merged
Merged
Conversation
- Number.toString had no `return`: the caller read what was left in the result register, which under gc happened to be the string and under rc, none and own crashed. - number.toString(radix) converts in radix 2 to 36 as JavaScript does: 16 was C's "%a" (0x1.fe00000000000p+7 for 255) and any other radix was ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Number.toStringhad noreturn: callers read whatever was left in the result register. Under gc that happened to be the string; under rc, none and ownnew Number(5).toString()crashed.number.toString(radix)converts in radix 2 to 36 as JavaScript does. Radix 16 was C's%a(0x1.fe00000000000p+7for 255) and any other radix was ignored. A power-of-two radix gives every digit; another radix is cut at 52 fraction digits.Independent of ASDAlexander77/TypeScriptCompiler#728.
Tests
tests/number_object_tostring.ts:new Number(5).toString(), radix 16/2/36, a negative fraction, zero,(0.1).toString(2)🤖 Generated with Claude Code