Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:core
  3. BigInt class
BigInt
description

BigInt classabstractfinal

An arbitrarily large integer value.

Big integers are signed and can have an arbitrary number ofsignificant digits, only limited by memory.

To create a big integer from the provided number, useBigInt.from.

var bigInteger = BigInt.from(-1); // -1bigInteger = BigInt.from(0.9999); // 0bigInteger = BigInt.from(-10.99); // -10bigInteger = BigInt.from(0x7FFFFFFFFFFFFFFF); // 9223372036854775807bigInteger = BigInt.from(1e+30); // 1000000000000000019884624838656

To parse a large integer value from a string, useparse ortryParse.

var value = BigInt.parse('0x1ffffffffffffffff'); // 36893488147419103231value = BigInt.parse('12345678901234567890'); // 12345678901234567890

To check whether a big integer can be represented as anint without losingprecision, useisValidInt.

print(bigNumber.isValidInt); // false

To convert a big integer into anint, usetoInt.To convert a big integer into andouble, usetoDouble.

var bigValue = BigInt.from(10).pow(3);print(bigValue.isValidInt); // trueprint(bigValue.toInt()); // 1000print(bigValue.toDouble()); // 1000.0

See also:

Implemented types

Constructors

BigInt.from(numvalue)
Creates a big integer from the providedvalue number.
factory

Properties

bitLengthint
Returns the minimum number of bits required to store this big integer.
no setter
hashCodeint
The hash code for this object.
no setterinherited
isEvenbool
Whether this big integer is even.
no setter
isNegativebool
Whether this number is negative.
no setter
isOddbool
Whether this big integer is odd.
no setter
isValidIntbool
Whether this big integer can be represented as anint without losingprecision.
no setter
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited
signint
Returns the sign of this big integer.
no setter

Methods

abs()BigInt
Returns the absolute value of this integer.
compareTo(BigIntother)int
Compares this toother.
override
gcd(BigIntother)BigInt
Returns the greatest common divisor of this big integer andother.
modInverse(BigIntmodulus)BigInt
Returns the modular multiplicative inverse of this big integermodulomodulus.
modPow(BigIntexponent,BigIntmodulus)BigInt
Returns this integer to the power ofexponent modulomodulus.
noSuchMethod(Invocationinvocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pow(intexponent)BigInt
Returnsthis to the power ofexponent.
remainder(BigIntother)BigInt
Returns the remainder of the truncating division ofthis byother.
toDouble()double
Returns thisBigInt as adouble.
toInt()int
Returns thisBigInt as anint.
toRadixString(intradix)String
Converts thisBigInt to a string representation in the givenradix.
toSigned(intwidth)BigInt
Returns the least significantwidth bits of this integer, extending thehighest retained bit to the sign. This is the same as truncating the valueto fit inwidth bits using an signed 2-s complement representation. Thereturned value has the same bit value in all positions higher thanwidth.
toString()String
Returns a String-representation of this integer.
override
toUnsigned(intwidth)BigInt
Returns the least significantwidth bits of this big integer as anon-negative number (i.e. unsigned representation). The returned value haszeros in all bit positions higher thanwidth.

Operators

operator %(BigIntother)BigInt
Euclidean modulo operator.
operator &(BigIntother)BigInt
Bit-wise and operator.
operator *(BigIntother)BigInt
Multipliesother by this big integer.
operator +(BigIntother)BigInt
Addsother to this big integer.
operator -(BigIntother)BigInt
Subtractsother from this big integer.
operator /(BigIntother)double
Double division operator.
operator<(BigIntother)bool
Whether this big integer is numerically smaller thanother.
operator<<(intshiftAmount)BigInt
Shift the bits of this integer to the left byshiftAmount.
operator<=(BigIntother)bool
Whetherother is numerically greater than this big integer.
operator ==(Objectother)bool
The equality operator.
inherited
operator >(BigIntother)bool
Whether this big integer is numerically greater thanother.
operator >=(BigIntother)bool
Whetherother is numerically smaller than this big integer.
operator >>(intshiftAmount)BigInt
Shift the bits of this integer to the right byshiftAmount.
operator ^(BigIntother)BigInt
Bit-wise exclusive-or operator.
operator unary-()BigInt
Return the negative value of this integer.
operator |(BigIntother)BigInt
Bit-wise or operator.
operator ~()BigInt
The bit-wise negate operator.
operator ~/(BigIntother)BigInt
Truncating integer division operator.

Static Properties

oneBigInt
A big integer with the numerical value 1.
no setter
twoBigInt
A big integer with the numerical value 2.
no setter
zeroBigInt
A big integer with the numerical value 0.
no setter

Static Methods

parse(Stringsource, {int?radix})BigInt
Parsessource as a, possibly signed, integer literal and returns itsvalue.
tryParse(Stringsource, {int?radix})BigInt?
Parsessource as a, possibly signed, integer literal and returns itsvalue.
  1. Dart
  2. dart:core
  3. BigInt class
dart:core library

[8]ページ先頭

©2009-2025 Movatter.jp