# bigint

## How large can a Java BigInteger be?

Java FAQ: How large can a Java `BigInteger` be?

“BigInteger must support values in the range -2Integer.MAX_VALUE (exclusive) to +2Integer.MAX_VALUE (exclusive) and may support values outside of that range.”

The Scala `BigInt` wraps Java’s `BigInteger`, so it will also have the same data range.

How to handle very large numbers in Scala (BigInt, BigDecimal) alvin July 10, 2017 - 2:10pm

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 2.6, “Handling Very Large Numbers in Scala.”

## Problem

You’re writing a Scala application and need to use very large integer or decimal numbers.

## Solution

Use the Scala `BigInt` and `BigDecimal` classes. You can create a `BigInt`:

## Scala: How to parse a number from a String

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 2.1, “Parsing a Number from a String.”

## Problem

You want to convert a `String` to one of Scala’s numeric types (`Byte`, `Double`, `Int`, `Float`, `Long`, `Short`).

## How to use BigInt and BigDecimal when you need very large numbers in Scala

Scala FAQ: I’m writing an application and I need to use very large integer or decimal (floating-point) numbers; what’s the best approach?

## Solution

Use the Scala `BigInt` and `BigDecimal` classes. You can create a `BigInt`:

```scala> var b = BigInt(1234567890)
b: scala.math.BigInt = 1234567890```

or a `BigDecimal`: