0

I have Int

val y = 10

I want to cast to BigInt

y.toBigInt 

it show error

<console>:26: error: value toBigInt is not a member of Int
       y.toBigInt

How can I cast Int to BigInt ?

1
  • 3
    why not val d :BigInt = 10 Commented Dec 7, 2018 at 8:46

2 Answers 2

8

Here is example:

val i: Int = 1
val bigInt = BigInt(i)
Sign up to request clarification or add additional context in comments.

Comments

4

All the obvious methods work. You can assign an Int to a BigInt, you can pass an Int to a function that takes BigInt, and you can just use BigInt(y).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.