Reputation: 322
object LPrimeFactor {
def main(arg:Array[String]):Unit = {
start(13195)
start(600851475143)
}
def start(until:Long){
var all_prime_fac:Array[Int] = Array()
var i = 2
(compile:compileIncremental) Compilation failed
integer number too large
Even though I changed the arg type to Long, it's still not fixed.
Upvotes: 1
Views: 2962
Reputation: 1410
Please remember literals values, if you has not any type direct suffix, the compiler try to get your numeric type values, such as 600851475143 as type Int, which is 32-bit length, two complement representation
MIN_VALUE = -2147483648(- 2 ^ 31)
MAX_VALUE = 2147483647(2 ^ 31 - 1)
So please add right suffix on the literal value, as 600851475143L
Upvotes: 0
Reputation: 8529
To create a Long literal you must add L
to the end of it.
start(600851475143L)
Upvotes: 1
Reputation: 19507
Pass the argument as a Long
(notice the L
at the end of the number):
start(600851475143L)
// ^
Upvotes: 2