Reputation: 4633
I wrote a pretty big program with many methods that use a variable as integer. Is there a way to change it fast to something else? Note that some methods use div and mod on that integer, so trying to change it into Arraylist would mean changing pretty much a lot of code.
I discovered too late that int is not enough to store the numbers that I need(coefficients of polynomials, that is; I though I was going to work with small ones, but ended up needing ones of bigger length than 9).
Upvotes: 2
Views: 4810
Reputation: 7304
You can use long, which will give you twice as many bits. If that's not big enough, you can move to BigInteger, which will give you as many as you want, however you won't be able to user operators (like div and mod) directly.
EDIT: The maximum value of a long is 9223372036854775807 (which is 2^63-1)
Upvotes: 5
Reputation: 151
long
would probably be what you want to replace them with. If you really do want to replace all instances of int
you could probably do something with grep to replace all of them. If you're using Eclipse you could just follow the instructions here.
If not and you're still on a Unix-like system you could use something like grep -rl int <project-directory>/ | xargs sed -i 's/int/long/g'
.
Upvotes: 0