Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scala won't take a 12-digit integer

Tags:

scala

ok so I'm just getting started in scala.. ran into a weird problem with a large number.

import Math._
var num:Long=0
num+=600851475
num*=1000
println(num)

that code works fine, yet the following doesn't compile with an error saying the integer is too large.

import Math._
var num:Long=0
num+=600851475000
println(num)

what's up? can scala not handle a 12-digit number? :/

like image 808
Chris Bolton Avatar asked Sep 05 '10 01:09

Chris Bolton


1 Answers

Your constant should be 600851475000L

like image 163
DigitalRoss Avatar answered Oct 07 '22 09:10

DigitalRoss