Skip to content

pkg/fixnum: Bring API closer to int. #145

@DartBot

Description

@DartBot

<img src="https://avatars.githubusercontent.com/u/2108821?v=3" align="left" width="96" height="96"hspace="10"> Issue by rakudrama
Originally opened as dart-lang/sdk#13383


Int64:

  static Int64 parseRadix(String s, int radix) {
  static Int64 parseInt(String s) => _parseRadix(s, 10);
  static Int64 parseHex(String s) => _parseRadix(s, 16);

Int32:

  static Int32 parseRadix(String s, int radix) {
  static Int32 parseInt(String s) => new Int32.fromInt(int.parse(s));
  static Int32 parseHex(String s) => parseRadix(s, 16);

int:

  external static int parse(String source,
                            { int radix,
                              int onError(String source) });

Int32/64 have toHexString().
They are inconsistent in how they handle negative values and in the case of the alphabetic characters.

Int32/64 are missing a lot of methods defined on num.
Most are probably not that interesting (isNaN, isInfinite, roundToDouble() ...)

This should be implemented:

  double toDouble(); // I have seen a workaround implemented as double.parse(thing64.toString())

This might be useful:

  IntXX clamp(lowerLimit, upperLimit);

These have been added to int and would make sense on IntXX:

  int bitLength();
  IntXX toSigned(int width);
  IntXX toUnsigned(int width);

int is missing bitCount() (issue dart-lang/sdk#5798).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions