BigInteger or not BigInteger?

前端 未结 3 1491
北恋
北恋 2021-01-17 13:31

In Java, most of the primitive types are signed (one bit is used to represent the +/-), and therefore when I exceed the limits of the type, I can get unexpected results, lik

3条回答
  •  花落未央
    2021-01-17 14:11

    Scala is really the solution here. In that language "operators" are really just in-fixed methods, and can be defined for arbitrary classes. In fact in your case they already are in the standard library. So you can have the power of special number representations but the clean syntax of Java primitive types.

    Scala is battle-hardened and will be fully interoperable with your Java code.

提交回复
热议问题