Skip to content

[SDK Library] Consider supporting parsing binary integers #45063

Open
@parlough

Description

@parlough

For some content I'm working on it would be nice if int.parse and int.tryParse natively supported parsing binary integers prefixed with 0b similar to how it handles hexadecimal 0x ones currently.

Implementing this work now would also simplify the implementation of binary integer literals in the future as included in the considered small and useful features list documented in the language repo. The CFE/analyzer currently use the method for their conversion of the literals to consistent decimal values.

Analyzer:
https://cs.opensource.google/dart/sdk/+/master:pkg/analyzer/tool/summary/mini_ast.dart;l=478
https://cs.opensource.google/dart/sdk/+/master:pkg/analyzer/lib/src/fasta/ast_builder.dart;l=2972

CFE:
https://cs.opensource.google/dart/sdk/+/master:pkg/front_end/lib/src/fasta/kernel/body_builder.dart;l=2444

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-coretype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions