在 Scala 中处理长类型参数 [英] Handling long type argument in Scala

查看:23
本文介绍了在 Scala 中处理长类型参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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) 编译失败

(compile:compileIncremental) Compilation failed

整数太大

即使我将 arg 类型更改为 Long,它仍然没有修复.

Even though I changed the arg type to Long, it's still not fixed.

推荐答案

将参数作为 Long 传递(注意数字末尾的 L):

Pass the argument as a Long (notice the L at the end of the number):

start(600851475143L)
               // ^

这篇关于在 Scala 中处理长类型参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆