What is the modulo operator for longs in Java?
问题 How do I find the modulo (%) of two long values in Java? My code says 'Integer number too large' followed by the number I'm trying to mod. I tried casting it to a long but it didn't work. Do I have to convert it to a BigInteger and use the remainder method? Thanks. 回答1: The % operator does work for longs. It sounds like you may have forgotten to stick L at the end of a numeric literal, as in 123456789L . Can we see your code? 回答2: You can only have an integer up to 2 147 483 647. If you want